chiark / gitweb /
config: New instead_distro feature
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 57159b70fd62cdba67c3568736bdd594ccd6221f..af710657502fc822ac6a04e64e68329941890840 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -102,6 +102,7 @@ our $remotename = 'dgit';
 our @ourdscfield = qw(Dgit Vcs-Dgit-Master);
 our $branchprefix = 'dgit';
 our $csuite;
+our $instead_distro;
 
 sub lbranch () { return "$branchprefix/$csuite"; }
 my $lbranch_re = '^refs/heads/'.$branchprefix.'/([^/.]+)$';
@@ -595,6 +596,7 @@ sub access_distros () {
     # Returns list of distros to try, in order
     #
     # We want to try:
+    #    0. `instead of' distro name(s) we have been pointed to
     #    1. the access_quirk distro, if any
     #    2a. the user's specified distro, or failing that  } basedistro
     #    2b. the distro calculated from the suite          }
@@ -602,6 +604,7 @@ sub access_distros () {
 
     my (undef,$quirkdistro) = access_quirk();
     unshift @l, $quirkdistro;
+    unshift @l, $instead_distro;
     return grep { defined } @l;
 }
 
@@ -975,6 +978,7 @@ sub get_archive_dsc () {
     $dsc = undef;
 }
 
+sub check_for_git ();
 sub check_for_git () {
     # returns 0 or 1
     my $how = access_cfg('git-check');
@@ -985,6 +989,14 @@ sub check_for_git () {
             " set -e; cd ".access_cfg('git-path').";".
             " if test -d $package.git; then echo 1; else echo 0; fi");
        my $r= cmdoutput @cmd;
+       if ($r =~ m/^divert (\w+)$/) {
+           my $divert=$1;
+           my ($usedistro,) = access_distros();
+           $instead_distro= cfg("dgit-distro.$usedistro.diverts.$divert");
+           $instead_distro =~ s{^/}{ access_basedistro()."/" }e;
+           printdebug "diverting $divert so using distro $instead_distro\n";
+           return check_for_git();
+       }
        failedcmd @cmd unless $r =~ m/^[01]$/;
        return $r+0;
     } elsif ($how eq 'true') {