appropriate for that repository (git, svn, etc).
The information about the repositories is embedded in the web page using
-the rel=vcs microformat, which is documented at
+the rel=vcs-* microformat, which is documented at
<http://kitenet.net/~joey/rfc/rel-vcs/>.
If the optional destdir parameter is specified, VCS programs will be asked
allows you to use authenticated repositories, you might want to use this
option.
-=item -n
+=item --no-act, -n
Do not actually check anything out, just print out the commands that would
be run to check out the repositories.
-=item -q
+=item --quiet, -q
Quiet mode. Do not print out the commands being run. (The VCS commands
may still be noisy however.)
# Controls whether to perfer repos that use authentication.
my $want_auth=0;
-# Controls where to check out to. If not set, the vcs is allowed to
+# Controls where to check out to. If not set, the VCS is allowed to
# decide.
my $destdir;
my @ret;
my $parser=HTML::Parser->new(api_version => 3);
+ my $abody=undef;
+ my $aref=undef;
$parser->handler(start => sub {
my $tagname=shift;
my $attr=shift;
- return if lc $tagname ne 'link';
- return if ! exists $attr->{rel} || lc $attr->{rel} ne 'vcs';
+
return if ! exists $attr->{href} || ! length $attr->{href};
- return if ! exists $attr->{type} || ! length $attr->{type};
+ return if ! exists $attr->{rel} || $attr->{rel} !~ /^vcs-(.+)/i;
+ $attr->{type}=lc($1);
+
+ # need to collect the body of the <a> tag if there is no title
+ if ($tagname eq "a" && ! exists $attr->{title}) {
+ $abody="";
+ $aref=$attr;
+ }
+
push @ret, $attr;
}, "tagname, attr");
+ $parser->handler(text => sub {
+ if (defined $aref) {
+ $abody.=join(" ", @_);
+ }
+ }, "text");
+ $parser->handler(end => sub {
+ my $tagname=shift;
+ if ($tagname eq "a" && defined $aref) {
+ $aref->{title}=$abody;
+ $aref=undef;
+ $abody=undef;
+ }
+ }, "tagname");
+ $parser->report_tags(qw{link a});
$parser->parse($page);
$parser->eof;
die "no repositories found on $url\n";
}
+#use Data::Dumper;
+#print Dumper(\@repos);
+#exit;
+
if (defined $destdir && @repos > 1) {
# create subdirs of $destdir for the multiple repos
if (! $noact) {
}
}
exit($errors > 0);
-
-#use Data::Dumper;
-#print Dumper(\@repos);