X-Git-Url: https://git.madduck.net/code/myrepos.git/blobdiff_plain/cd7b0331b72123ca22a88f833b6c0bb3e3d9d15e..7cbacd59bf538bac9e5868a005be162b265e44d6:/webcheckout?ds=sidebyside diff --git a/webcheckout b/webcheckout index c97e40b..4841fee 100755 --- a/webcheckout +++ b/webcheckout @@ -152,21 +152,26 @@ sub better { sub dedup { my %seenhref; my %bytitle; + my @others; foreach my $repo (@_) { if (exists $repo->{title} && - length $repo->{title} && - exists $bytitle{$repo->{title}}) { - my $other=$bytitle{$repo->{title}}; - next unless better($repo, $other); - delete $bytitle{$other->{title}} + length $repo->{title}) { + if (exists $bytitle{$repo->{title}}) { + my $other=$bytitle{$repo->{title}}; + next unless better($repo, $other); + delete $bytitle{$other->{title}} + } + + if (! $seenhref{$repo->{href}}++) { + $bytitle{$repo->{title}}=$repo; + } } - - if (! $seenhref{$repo->{href}}++) { - $bytitle{$repo->{title}}=$repo; + else { + push @others, $repo; } } - return values %bytitle; + return values %bytitle, @others; } sub parse { @@ -190,7 +195,6 @@ sub parse { } getopts(); -print "$url\n"; my $page=get($url); if (! defined $page) { @@ -204,8 +208,10 @@ if (! @repos) { if (defined $destdir && @repos > 1) { # create subdirs of $destdir for the multiple repos - mkdir($destdir); - chdir($destdir) || die "failed to chdir to $destdir: $!"; + if (! $noact) { + mkdir($destdir); + chdir($destdir) || die "failed to chdir to $destdir: $!"; + } $destdir=undef; }