chiark / gitweb /
New --damp-run mode, for more convenient and fuller testing etc.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Oct 2013 11:50:06 +0000 (12:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Oct 2013 11:50:06 +0000 (12:50 +0100)
debian/changelog
dgit
dgit.1

index be125f83ca528666c0d9410c76e63e8a0b2a8046..0a499cb099adbffc8083c1e83b8bae8bf2c4c276 100644 (file)
@@ -2,6 +2,7 @@ dgit (0.16) unstable; urgency=low
 
   * Set autoflush on stdout, to get better ordering of debugging
     etc. output when stdout is redirected.
+  * New --damp-run mode, for more convenient and fuller testing etc.
 
  --
 
diff --git a/dgit b/dgit
index 083086b40b11b102d0ded4c58ca54330a82b6d2e..3c13d79f66182a9579b6f56268161f6c9d9e3716 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -211,6 +211,14 @@ sub runcmd_ordryrun {
     }
 }
 
+sub runcmd_ordryrun_local {
+    if ($dryrun <= 1) {
+       runcmd @_;
+    } else {
+       dryrun_report @_;
+    }
+}
+
 sub shell_cmd {
     my ($first_shell, @cmd) = @_;
     return qw(sh -ec), $first_shell.'; exec "$@"', 'x', @cmd;
@@ -225,6 +233,7 @@ main usages:
 important dgit options:
   -k<keyid>           sign tag and package with <keyid> instead of default
   --dry-run -n        do not change anything, but go through the motions
+  --damp-run -L       like --dry-run but make local changes, without signing
   --new -N            allow introducing a new package
   --debug -D          increase debug level
   -c<name>=<value>    set git config option (used directly by dgit too)
@@ -670,7 +679,7 @@ sub ensure_we_have_orig () {
        $origurl .= "/$f";
        die "$f ?" unless $f =~ m/^${package}_/;
        die "$f ?" if $f =~ m#/#;
-       runcmd_ordryrun shell_cmd 'cd ..', @dget,'--',$origurl;
+       runcmd_ordryrun_local shell_cmd 'cd ..', @dget,'--',$origurl;
     }
 }
 
@@ -691,7 +700,7 @@ sub is_fast_fwd ($$) {
 }
 
 sub git_fetch_us () {
-    runcmd_ordryrun @git, qw(fetch),access_giturl(),fetchspec();
+    runcmd_ordryrun_local @git, qw(fetch),access_giturl(),fetchspec();
 }
 
 sub fetch_from_archive () {
@@ -798,7 +807,7 @@ END
     }
     if ($lastpush_hash ne $hash) {
        my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
-       if (!$dryrun) {
+       if ($dryrun <= 1) {
            cmdoutput @upd_cmd;
        } else {
            dryrun_report @upd_cmd;
@@ -810,7 +819,7 @@ END
 sub clone ($) {
     my ($dstdir) = @_;
     canonicalise_suite();
-    badusage "dry run makes no sense with clone" if $dryrun;
+    badusage "dry run makes no sense with clone" if $dryrun > 1;
     mkdir $dstdir or die "$dstdir $!";
     chdir "$dstdir" or die "$dstdir $!";
     runcmd @git, qw(init -q);
@@ -822,7 +831,7 @@ sub clone ($) {
     if (check_for_git()) {
        print "fetching existing git history\n";
        git_fetch_us();
-       runcmd_ordryrun @git, qw(fetch origin);
+       runcmd_ordryrun_local @git, qw(fetch origin);
     } else {
        print "starting new git history\n";
     }
@@ -841,7 +850,7 @@ sub fetch () {
 
 sub pull () {
     fetch();
-    runcmd_ordryrun @git, qw(merge -m),"Merge from $csuite [dgit]",
+    runcmd_ordryrun_local @git, qw(merge -m),"Merge from $csuite [dgit]",
         lrref();
     printdone "fetched to ".lrref()." and merged into HEAD";
 }
@@ -877,10 +886,10 @@ sub commit_quilty_patch () {
        print "nothing quilty to commit, ok.\n";
        return;
     }
-    runcmd_ordryrun @git, qw(add), sort keys %adds;
+    runcmd_ordryrun_local @git, qw(add), sort keys %adds;
     my $m = "Commit Debian 3.0 (quilt) metadata";
     print "$m\n";
-    runcmd_ordryrun @git, qw(commit -m), $m;
+    runcmd_ordryrun_local @git, qw(commit -m), $m;
 }
 
 sub madformat ($) {
@@ -976,11 +985,14 @@ sub dopush () {
        if (!defined $keyid) {
            $keyid = access_cfg('keyid','RETURN-UNDEF');
        }
-       my @tag_cmd = (@git, qw(tag -s -m),
+       my @tag_cmd = (@git, qw(tag -m),
                       "$package release $dversion for $csuite [dgit]");
-       push @tag_cmd, qw(-u),$keyid if defined $keyid;
+       if ($dryrun != 1) {
+           push @tag_cmd, qw(-s);
+           push @tag_cmd, qw(-u),$keyid if defined $keyid;
+       }
        push @tag_cmd, $tag;
-       runcmd_ordryrun @tag_cmd;
+       runcmd_ordryrun_local @tag_cmd;
        my @debsign_cmd = @debsign;
        push @debsign_cmd, "-k$keyid" if defined $keyid;
        push @debsign_cmd, $changesfile;
@@ -1130,7 +1142,7 @@ END
        local $ENV{'EDITOR'} = cmdoutput qw(realpath --), $0;
        local $ENV{'VISUAL'} = $ENV{'EDITOR'};
        local $ENV{$fakeeditorenv} = cmdoutput qw(realpath --), $descfn;
-       runcmd_ordryrun @dpkgsource, qw(--commit .), $patchname;
+       runcmd_ordryrun_local @dpkgsource, qw(--commit .), $patchname;
     }
 
     if (!open P, '>>', ".pc/applied-patches") {
@@ -1175,7 +1187,7 @@ sub cmd_build {
     badusage "dgit build implies --clean=dpkg-source"
        if $cleanmode ne 'dpkg-source';
     build_prep();
-    runcmd_ordryrun @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
+    runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV;
     printdone "build successful\n";
 }
 
@@ -1191,7 +1203,7 @@ sub cmd_git_build {
        push @cmd, "--git-debian-branch=".lbranch();
     }
     push @cmd, changesopts();
-    runcmd_ordryrun @cmd, @ARGV;
+    runcmd_ordryrun_local @cmd, @ARGV;
     printdone "build successful\n";
 }
 
@@ -1200,10 +1212,11 @@ sub build_source {
     $sourcechanges = "${package}_".(stripepoch $version)."_source.changes";
     $dscfn = dscfn($version);
     if ($cleanmode eq 'dpkg-source') {
-       runcmd_ordryrun (@dpkgbuildpackage, qw(-us -uc -S)), changesopts();
+       runcmd_ordryrun_local (@dpkgbuildpackage, qw(-us -uc -S)),
+           changesopts();
     } else {
        if ($cleanmode eq 'git') {
-           runcmd_ordryrun @git, qw(clean -xdf);
+           runcmd_ordryrun_local @git, qw(clean -xdf);
        } elsif ($cleanmode eq 'none') {
        } else {
            die "$cleanmode ?";
@@ -1211,9 +1224,9 @@ sub build_source {
        my $pwd = cmdoutput qw(env - pwd);
        my $leafdir = basename $pwd;
        chdir ".." or die $!;
-       runcmd_ordryrun @dpkgsource, qw(-b --), $leafdir;
+       runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir;
        chdir $pwd or die $!;
-       runcmd_ordryrun qw(sh -ec),
+       runcmd_ordryrun_local qw(sh -ec),
            'exec >$1; shift; exec "$@"','x',
            "../$sourcechanges",
            @dpkggenchanges, qw(-S), changesopts();
@@ -1230,7 +1243,7 @@ sub cmd_sbuild {
     build_source();
     chdir ".." or die $!;
     my $pat = "${package}_".(stripepoch $version)."_*.changes";
-    if (!$dryrun) {
+    if ($dryrun <= 1) {
        stat $dscfn or fail "$dscfn (in parent directory): $!";
        stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
        foreach my $cf (glob $pat) {
@@ -1241,7 +1254,7 @@ sub cmd_sbuild {
     runcmd_ordryrun @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
     runcmd_ordryrun @mergechanges, glob $pat;
     my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
-    if (!$dryrun) {
+    if ($dryrun <= 1) {
        stat $multichanges or fail "$multichanges: $!";
     }
     printdone "build successful, results in $multichanges\n" or die $!;
@@ -1267,6 +1280,8 @@ sub parseopts () {
        last if m/^--?$/;
        if (m/^--/) {
            if (m/^--dry-run$/) {
+               $dryrun=2;
+           } elsif (m/^--damp-run$/) {
                $dryrun=1;
            } elsif (m/^--no-sign$/) {
                $sign=0;
@@ -1301,6 +1316,8 @@ sub parseopts () {
        } else {
            while (m/^-./s) {
                if (s/^-n/-/) {
+                   $dryrun=2;
+               } elsif (s/^-L/-/) {
                    $dryrun=1;
                } elsif (s/^-h/-/) {
                    cmd_help();
@@ -1341,7 +1358,8 @@ if ($ENV{$fakeeditorenv}) {
 delete $ENV{'DGET_UNPACK'};
 
 parseopts();
-print STDERR "DRY RUN ONLY\n" if $dryrun;
+print STDERR "DRY RUN ONLY\n" if $dryrun > 1;
+print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n" if $dryrun == 1;
 if (!@ARGV) {
     print STDERR $helpmsg or die $!;
     exit 8;
diff --git a/dgit.1 b/dgit.1
index 251af593181580eb1d818bf6f74bb9f830bbbdae..3c1a8f00b8a359bac2d784e6cd607d0a2f1306d6 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -162,6 +162,11 @@ actually update the output(s).  For push, dgit does
 the required checks and leaves the new .dsc in a temporary file,
 but does not sign, tag, push or upload.
 .TP
+.BR --damp-run | -L
+Go through many more of the motions: do everything that doesn't
+involve either signing things, or making changes on the public
+servers.
+.TP
 .BI -k keyid
 Use
 .I keyid