summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog3
-rwxr-xr-xdgit48
-rw-r--r--dgit.122
3 files changed, 73 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 2bd9883..6bc6173 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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.
+ * 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
diff --git a/dgit b/dgit
index 5a6b2b6..48fd4f4 100755
--- 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.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"
@@ -4621,6 +4622,53 @@ END
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();
diff --git a/dgit.1 b/dgit.1
index 6ee22e8..8ddcbe3 100644
--- 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.
+(See also dgit update-vcs-git.)
.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
+\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
@@ -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.
+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
@@ -1173,6 +1193,8 @@ or when pushing and
.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