chiark / gitweb /
dgit: Provide `update-vcs-git' subcommand
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 21 Jun 2018 13:05:26 +0000 (14:05 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 21 Jun 2018 16:19:39 +0000 (17:19 +0100)
This is for creating and adjusting the vcs-git remote url.  Useful for
transition from alioth to salsa.  Closes:#902006.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit
dgit.1

index 2bd98835a081cf820d53f1f657fd867d24bff111..6bc61735c3b727421dc440bd2edeb1e67d9bfc8e 100644 (file)
@@ -21,6 +21,9 @@ dgit (5.2~) unstable; urgency=medium
   * --overwrite now no longer crashes if there is nothing to overwrite
     (eg, when used with --new).  Instead, it is simply ignored, as it is
     ignored in situations where the push is fast forward.  Closes:#863576.
   * --overwrite now no longer crashes if there is nothing to overwrite
     (eg, when used with --new).  Instead, it is simply ignored, as it is
     ignored in situations where the push is fast forward.  Closes:#863576.
+  * Provide `update-vcs-git' subcommand, for creating and adjusting the
+    vcs-git remote url.  Useful for transition from alioth to salsa.
+    Closes:#902006.
 
   test suite:
   * Use nproc(1) rather than Sys::CPU.  This is more portable and does not
 
   test suite:
   * Use nproc(1) rather than Sys::CPU.  This is more portable and does not
diff --git a/dgit b/dgit
index 5a6b2b68ea8c1937a0b4622a243c201b86137891..48fd4f487707be2c992e2dfaad56f0caac50e30c 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -617,6 +617,7 @@ our %defcfg = ('dgit.default.distro' => 'debian',
               'dgit.dsc-url-proto-ok.http'    => 'true',
               'dgit.dsc-url-proto-ok.https'   => 'true',
               'dgit.dsc-url-proto-ok.git'     => 'true',
               'dgit.dsc-url-proto-ok.http'    => 'true',
               'dgit.dsc-url-proto-ok.https'   => 'true',
               'dgit.dsc-url-proto-ok.git'     => 'true',
+              'dgit.vcs-git.suites',          => 'sid', # ;-separated
               'dgit.default.dsc-url-proto-ok' => 'false',
               # old means "repo server accepts pushes with old dgit tags"
               # new means "repo server accepts pushes with new dgit tags"
               'dgit.default.dsc-url-proto-ok' => 'false',
               # old means "repo server accepts pushes with old dgit tags"
               # new means "repo server accepts pushes with new dgit tags"
@@ -4621,6 +4622,53 @@ END
     pull();
 }
 
     pull();
 }
 
+sub cmd_update_vcs_git () {
+    my $specsuite;
+    if (@ARGV==0 || $ARGV[0] =~ m/^-/) {
+       ($specsuite,) = split /\;/, cfg 'dgit.vcs-git.suites';
+    } else {
+       ($specsuite) = (@ARGV);
+       shift @ARGV;
+    }
+    my $dofetch=1;
+    if (@ARGV) {
+       if ($ARGV[0] eq '-') {
+           $dofetch = 0;
+       } elsif ($ARGV[0] eq '-') {
+           shift;
+       }
+    }
+
+    my $sourcep = parsecontrol 'debian/control', 'debian/control';
+    $package = getfield $sourcep, 'Source';
+    my $ctrl;
+    if ($specsuite eq '.') {
+       $ctrl = $sourcep;
+    } else {
+       $isuite = $specsuite;
+       get_archive_dsc();
+       $ctrl = $dsc;
+    }
+    my $url = getfield $ctrl, 'Vcs-Git';
+
+    my @cmd;
+    my $orgurl = cfg 'remote.vcs-git.url', 'RETURN-UNDEF';
+    if (!defined $orgurl) {
+       print STDERR "setting up vcs-git: $url\n";
+       @cmd = (@git, qw(remote add vcs-git), $url);
+    } elsif ($orgurl eq $url) {
+       print STDERR "vcs git already configured: $url\n";
+    } else {
+       print STDERR "changing vcs-git url to: $url\n";
+       @cmd = (@git, qw(remote set-url vcs-git), $url);
+    }
+    runcmd_ordryrun_local @cmd;
+    if ($dofetch) {
+       print "fetching (@ARGV)\n";
+       runcmd_ordryrun_local @git, qw(fetch vcs-git), @ARGV;
+    }
+}
+
 sub prep_push () {
     parseopts();
     build_or_push_prep_early();
 sub prep_push () {
     parseopts();
     build_or_push_prep_early();
diff --git a/dgit.1 b/dgit.1
index 6ee22e822082330ad82f2f2d0ac85c27a82881d2..8ddcbe39c354322d61ddb7ec93ea7502c4c906f5 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -88,6 +88,7 @@ For your convenience, the
 remote will be set up from the package's Vcs-Git field, if there is
 one - but note that in the general case the history found there may be
 different to or even disjoint from dgit's view.
 remote will be set up from the package's Vcs-Git field, if there is
 one - but note that in the general case the history found there may be
 different to or even disjoint from dgit's view.
+(See also dgit update-vcs-git.)
 .TP
 \fBdgit fetch\fR [\fIsuite\fP]
 Consults the archive and git-repos to update the git view of
 .TP
 \fBdgit fetch\fR [\fIsuite\fP]
 Consults the archive and git-repos to update the git view of
@@ -139,6 +140,20 @@ push-source, or dgit push.
 Cleans the current working tree (according to the --clean= option in
 force).
 .TP
 Cleans the current working tree (according to the --clean= option in
 force).
 .TP
+\fBdgit update-vcs-git\fR [\fIsuite\fP|\fB.\fR] [\fB--\fR] [\fIgit fetch options\fR]
+.TQ
+\fBdgit update-vcs-git\fR [\fIsuite|\fP\fB.\fR] \fB-\fR
+Sets up, or updates the url of, the vcs-git remote, and
+(unless \fB-\fR was specified)
+runs git fetch on it.
+
+By default, the Vcs-Git field of the .dsc from Debian sid is used,
+as that is probably most up to date.
+Another suite may be specified, or
+.B .
+to indicate that the Vcs-Git of the cwd's debian/control should
+be used instead.
+.TP
 .B dgit help
 Print a usage summary.
 .TP
 .B dgit help
 Print a usage summary.
 .TP
@@ -246,6 +261,11 @@ and
 (but only does each thing if dgit is configured to do it automatically).
 You can use these in any git repository, not just ones used with
 the other dgit operations.
 (but only does each thing if dgit is configured to do it automatically).
 You can use these in any git repository, not just ones used with
 the other dgit operations.
+Does
+.B not
+run
+.B update-vcs-git
+(as that requires Debian packaging information).
 .TP
 .B dgit setup-useremail
 Set the working tree's user.name and user.email from the
 .TP
 .B dgit setup-useremail
 Set the working tree's user.name and user.email from the
@@ -1173,6 +1193,8 @@ or when pushing and
 .BI dgit.dsc-url-proto-ok.bad-syntax
 .TP
 .BI dgit.default.dsc-url-proto-ok
 .BI dgit.dsc-url-proto-ok.bad-syntax
 .TP
 .BI dgit.default.dsc-url-proto-ok
+.TP
+.BR dgit.vcs-git.suites " \fIsuite\fR[" ; ...]
 .SH ENVIRONMENT VARIABLES
 .TP
 .BR DGIT_SSH ", " GIT_SSH
 .SH ENVIRONMENT VARIABLES
 .TP
 .BR DGIT_SSH ", " GIT_SSH