chiark / gitweb /
dgit: Use a regexp to match clean mode check
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 9c1f3e51e02d3697ec2a0b3875eabe0568ca4dc7..2d7b8d4a7cb987ed207fd584e1bd9c54e7587bc1 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -6199,36 +6199,39 @@ sub maybe_unapply_patches_again () {
 
 #----- other building -----
 
+sub clean_tree_check () {
+    # Not yet fully implemented.
+    if ($cleanmode =~ m{^check}) {
+       my $leftovers = cmdoutput @git, qw(clean -xdn);
+       if (length $leftovers) {
+           print STDERR $leftovers, "\n" or confess $!;
+           fail __
+ "tree contains uncommitted files and --clean=check specified";
+       }
+    }
+}
+
 sub clean_tree () {
     # We always clean the tree ourselves, rather than leave it to the
     # builder (dpkg-source, or soemthing which calls dpkg-source).
-    if ($cleanmode eq 'dpkg-source') {
-       maybe_apply_patches_dirtily();
-       runcmd_ordryrun_local @dpkgbuildpackage, qw(-T clean);
-    } elsif ($cleanmode eq 'dpkg-source-d') {
+    if ($cleanmode =~ m{^dpkg-source}) {
+       my @cmd = @dpkgbuildpackage;
+       push @cmd, qw(-d) if $cleanmode =~ m{^dpkg-source-d};
+       push @cmd, qw(-T clean);
        maybe_apply_patches_dirtily();
-       runcmd_ordryrun_local @dpkgbuildpackage, qw(-d -T clean);
+       runcmd_ordryrun_local @cmd;
     } elsif ($cleanmode eq 'git') {
        runcmd_ordryrun_local @git, qw(clean -xdf);
     } elsif ($cleanmode eq 'git-ff') {
        runcmd_ordryrun_local @git, qw(clean -xdff);
-    } elsif ($cleanmode eq 'check') {
-       my $leftovers = cmdoutput @git, qw(clean -xdn);
-       if (length $leftovers) {
-           print STDERR $leftovers, "\n" or confess $!;
-           fail __
- "tree contains uncommitted files and --clean=check specified";
-       }
+    } elsif ($cleanmode =~ m{^check}) {
+       clean_tree_check();
     } elsif ($cleanmode eq 'none') {
     } else {
        die "$cleanmode ?";
     }
 }
 
-sub clean_tree_check () {
-    # Not yet implemented.  The lack of this is part of #910705.
-}
-
 sub cmd_clean () {
     badusage __ "clean takes no additional arguments" if @ARGV;
     notpushing();