Control: tags -1 + patch Hello!
Please see attached patch for implementing usage of pushurl for git checkouts in devscripts. Please review carefully as I'm no perl expert. (Please reindent as needed, I couldn't make sense of the mixed tab/space...) Once this is merged, it might be a good idea to consider making auth the default for all git checkouts. Regards, Andreas Henriksson
diff -Nru devscripts-2.14.10/debian/changelog devscripts-2.14.10+nmu1/debian/changelog --- devscripts-2.14.10/debian/changelog 2014-10-14 04:35:45.000000000 +0200 +++ devscripts-2.14.10+nmu1/debian/changelog 2014-11-09 02:07:58.000000000 +0100 @@ -1,3 +1,10 @@ +devscripts (2.14.10+nmu1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Add git pushurl support for authenticated checkouts. + + -- Andreas Henriksson <andr...@fatal.se> Sun, 09 Nov 2014 02:07:00 +0100 + devscripts (2.14.10) unstable; urgency=medium * Fix all the other calls to dpkg-architecture in devscripts. diff -Nru devscripts-2.14.10/scripts/debcheckout.pl devscripts-2.14.10+nmu1/scripts/debcheckout.pl --- devscripts-2.14.10/scripts/debcheckout.pl 2014-10-14 04:35:45.000000000 +0200 +++ devscripts-2.14.10+nmu1/scripts/debcheckout.pl 2014-11-09 03:27:21.000000000 +0100 @@ -519,9 +519,9 @@ } # Checkout a given repository in a given destination directory. -sub checkout_repo($$$) { - my ($repo_type, $repo_url, $destdir) = @_; - my @cmd; +sub checkout_repo($$$;$) { + my ($repo_type, $repo_url, $destdir, $anon_repo_url) = @_; + my (@cmd, @extracmd); given ($repo_type) { when ("arch") { @cmd = ("tla", "grab", $repo_url); } # XXX ??? @@ -534,11 +534,28 @@ } when ("darcs") { @cmd = ("darcs", "get", $repo_url); } when ("git") { + my $pushurl; + + if (defined $anon_repo_url and length $anon_repo_url) { + if ($repo_url =~ m|(.*)\s+-b\s+(.*)|) { + $pushurl = $1; + } else { + $pushurl = $repo_url; + } + + $repo_url = $anon_repo_url; + } + if ($repo_url =~ m|(.*)\s+-b\s+(.*)|) { @cmd = ("git", "clone", $1, "-b", $2); } else { @cmd = ("git", "clone", $repo_url); } + + if ($pushurl) { + @extracmd = ("git", "remote", "set-url", "--push", "origin", + $pushurl); + } } when ("hg") { @cmd = ("hg", "clone", $repo_url); } when ("svn") { @cmd = ("svn", "co", $repo_url); } @@ -548,6 +565,25 @@ print "@cmd ...\n"; system @cmd; my $rc = $? >> 8; + + if ($rc == 0 && @extracmd) { + my $oldcwd = getcwd(); + my $checkoutdir; + + print "@extracmd ...\n"; + + if (length $destdir) { + $checkoutdir = $destdir; + } else { + ($checkoutdir = $repo_url) =~ s|.*/(.*)(.git?)|$1|; + } + + chdir($checkoutdir); + system @extracmd; + $rc = $? >> 8; + chdir($oldcwd); + } + return $rc; } @@ -988,6 +1024,7 @@ my $use_package = ''; # use this package instead of guessing from the URL my $repo_type = "svn"; # default repo typo, overridden by '-t' my $repo_url = ""; # repository URL + my $anon_repo_url; # repository URL (pre-auth mangling) my $user = ""; # login name (authenticated mode only) my $browse_url = ""; # online browsable repository URL my $git_track = ""; # list of remote GIT branches to --track @@ -1073,8 +1110,10 @@ } $repo_url = munge_url($repo_type, $repo_url); - $repo_url = set_auth($repo_type, $repo_url, $user, $dont_act) - if $auth and not @files; + if ($auth and not @files) { + $anon_repo_url = $repo_url; + $repo_url = set_auth($repo_type, $repo_url, $user, $dont_act); + } print_repo($repo_type, $repo_url) if $print_mode; # ... then quit print_details($repo_type, $repo_url) if $details_mode; # ... then quit if (length $pkg) { @@ -1085,7 +1124,7 @@ if (@files) { $rc = checkout_files($repo_type, $repo_url, $destdir, $browse_url); } else { - $rc = checkout_repo($repo_type, $repo_url, $destdir); + $rc = checkout_repo($repo_type, $repo_url, $destdir, $anon_repo_url); } # XXX: there is no way to know for sure what is the destdir :-( die "checkout failed (the command above returned a non-zero exit code)\n" if $rc != 0;