chiark / gitweb /
Break out $cleanmode_re (nfc)
[dgit.git] / dgit
diff --git a/dgit b/dgit
index ad460d14add2d9e696f9d10e416c784cbb4d8958..d7d27f834c4c9d349ceb2e78553c2852a239464b 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -67,6 +67,7 @@ our $initiator_tempdir;
 our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
 
 our $suite_re = '[-+.0-9a-z]+';
+our $cleanmode_re = 'dpkg-source(?:-d)?|git|git-ff|check|none';
 
 our (@git) = qw(git);
 our (@dget) = qw(dget);
@@ -2944,8 +2945,8 @@ sub changesopts () {
     return (changesopts_initial(), changesopts_version());
 }
 
-sub massage_dbp_args ($) {
-    my ($cmd) = @_;
+sub massage_dbp_args ($;$) {
+    my ($cmd,$xargs) = @_;
     if ($cleanmode eq 'dpkg-source') {
        $suppress_clean = 1;
        return;
@@ -2956,7 +2957,7 @@ sub massage_dbp_args ($) {
     push @newcmd, '-nc';
     # and some combinations of -S, -b, et al, are errors, rather than
     # later simply overriding earlier
-    push @newcmd, '-F' unless grep { m/^-[bBASF]$/ } @$cmd;
+    push @newcmd, '-F' unless grep { m/^-[bBASF]$/ } (@$cmd, @$xargs);
     push @newcmd, @$cmd;
     @$cmd = @newcmd;
 }
@@ -2972,10 +2973,16 @@ sub cmd_build {
 
 sub cmd_gbp_build {
     my @dbp = @dpkgbuildpackage;
-    massage_dbp_args \@dbp;
-    my @cmd =
-       (qw(git-buildpackage -us -uc --git-no-sign-tags),
-        "--git-builder=@dbp");
+    massage_dbp_args \@dbp, \@ARGV;
+
+    my @cmd;
+    if (length executable_on_path('git-buildpackage')) {
+       @cmd = qw(git-buildpackage);
+    } else {
+       @cmd = qw(gbp buildpackage);
+    }
+    push @cmd, (qw(-us -uc --git-no-sign-tags), "--git-builder=@dbp");
+
     if ($cleanmode eq 'dpkg-source') {
        $suppress_clean = 1;
     } else {
@@ -3158,7 +3165,7 @@ sub parseopts () {
            } elsif (m/^--build-products-dir=(.*)/s) {
                push @ropts, $_;
                $buildproductsdir = $1;
-           } elsif (m/^--clean=(dpkg-source(?:-d)?|git|git-ff|check|none)$/s) {
+           } elsif (m/^--clean=($cleanmode_re)$/os) {
                push @ropts, $_;
                $cleanmode = $1;
            } elsif (m/^--clean=(.*)$/s) {