summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2013-10-22 15:09:25 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2013-10-22 15:09:25 +0100
commit41e0ec2b26cba9b3d4016b195ec8795ca1bd40f4 (patch)
tree96da6c0127b11e46a467e72eaae8a72b69288a50
parent59235957912b6f55e150d533749aad62b1647e8e (diff)
Fix dgit --damp-run sbuild to actually work.
Improvements to implementation of --dry-run and --damp-run. * Rename $dryrun to $dryrun_level to catch all references * Introduce act_scary() and act_local() abstractions to make decison "if"s less confusing
-rw-r--r--debian/changelog7
-rwxr-xr-xdgit42
2 files changed, 30 insertions, 19 deletions
diff --git a/debian/changelog b/debian/changelog
index 6142585..8c37c8f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+dgit (0.17) unstable; urgency=low
+
+ * Fix dgit --damp-run sbuild to actually work.
+ * Improvements to implementation of --dry-run and --damp-run.
+
+ --
+
dgit (0.16) unstable; urgency=high
* Format `(3.0) quilt' fixup does not mind extraneous other files
diff --git a/dgit b/dgit
index e46da88..b1ed904 100755
--- a/dgit
+++ b/dgit
@@ -38,7 +38,7 @@ our $package;
our @ropts;
our $sign = 1;
-our $dryrun = 0;
+our $dryrun_level = 0;
our $changesfile;
our $new_package = 0;
our $ignoredirty = 0;
@@ -337,8 +337,11 @@ sub runcmd {
failedcmd @_ if system @_;
}
+sub act_local () { return $dryrun_level <= 1; }
+sub act_scary () { return !$dryrun_level; }
+
sub printdone {
- if (!$dryrun) {
+ if (!$dryrun_level) {
progress "dgit ok: @_";
} else {
progress "would be ok: @_ (but dry run only)";
@@ -371,7 +374,7 @@ sub dryrun_report {
}
sub runcmd_ordryrun {
- if (!$dryrun) {
+ if (act_scary()) {
runcmd @_;
} else {
dryrun_report @_;
@@ -379,7 +382,7 @@ sub runcmd_ordryrun {
}
sub runcmd_ordryrun_local {
- if ($dryrun <= 1) {
+ if (act_local()) {
runcmd @_;
} else {
dryrun_report @_;
@@ -1004,7 +1007,7 @@ END
}
if ($lastpush_hash ne $hash) {
my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
- if ($dryrun <= 1) {
+ if (act_local()) {
cmdoutput @upd_cmd;
} else {
dryrun_report @upd_cmd;
@@ -1016,7 +1019,7 @@ END
sub clone ($) {
my ($dstdir) = @_;
canonicalise_suite();
- badusage "dry run makes no sense with clone" if $dryrun > 1;
+ badusage "dry run makes no sense with clone" unless act_local();
mkdir $dstdir or die "$dstdir $!";
chdir "$dstdir" or die "$dstdir $!";
runcmd @git, qw(init -q);
@@ -1163,7 +1166,7 @@ END
push @sign_cmd, qw(-u),$keyid if defined $keyid;
push @sign_cmd, $tfn->('.tmp');
runcmd_ordryrun @sign_cmd;
- if (!$dryrun) {
+ if (act_scary()) {
$tagobjfn = $tfn->('.signed.tmp');
runcmd shell_cmd "exec >$tagobjfn", qw(cat --),
$tfn->('.tmp'), $tfn->('.tmp.asc');
@@ -1272,7 +1275,7 @@ sub dopush () {
runcmd_ordryrun @git, qw(update-ref -m), 'dgit push', lrref(), 'HEAD';
if (!$we_are_responder) {
- if ($dryrun <= 1) {
+ if (act_local()) {
rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
} else {
progress "[new .dsc left in $dscfn.tmp]";
@@ -1280,7 +1283,7 @@ sub dopush () {
}
if ($we_are_responder) {
- my $dryrunsuffix = $dryrun > 1 ? ".tmp" : "";
+ my $dryrunsuffix = act_local() ? "" : ".tmp";
responder_receive_files('signed-dsc-changes',
"../$dscfn$dryrunsuffix",
"$changesfile$dryrunsuffix");
@@ -1684,7 +1687,7 @@ sub cmd_sbuild {
build_source();
chdir ".." or die $!;
my $pat = "${package}_".(stripepoch $version)."_*.changes";
- if ($dryrun <= 1) {
+ if (act_local()) {
stat $dscfn or fail "$dscfn (in parent directory): $!";
stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
foreach my $cf (glob $pat) {
@@ -1692,10 +1695,10 @@ sub cmd_sbuild {
unlink $cf or fail "remove $cf: $!";
}
}
- runcmd_ordryrun @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
- runcmd_ordryrun @mergechanges, glob $pat;
+ runcmd_ordryrun_local @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
+ runcmd_ordryrun_local @mergechanges, glob $pat;
my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
- if ($dryrun <= 1) {
+ if (act_local()) {
stat $multichanges or fail "$multichanges: $!";
}
printdone "build successful, results in $multichanges\n" or die $!;
@@ -1731,10 +1734,10 @@ sub parseopts () {
if (m/^--/) {
if (m/^--dry-run$/) {
push @ropts, $_;
- $dryrun=2;
+ $dryrun_level=2;
} elsif (m/^--damp-run$/) {
push @ropts, $_;
- $dryrun=1;
+ $dryrun_level=1;
} elsif (m/^--no-sign$/) {
push @ropts, $_;
$sign=0;
@@ -1779,10 +1782,10 @@ sub parseopts () {
while (m/^-./s) {
if (s/^-n/-/) {
push @ropts, $&;
- $dryrun=2;
+ $dryrun_level=2;
} elsif (s/^-L/-/) {
push @ropts, $&;
- $dryrun=1;
+ $dryrun_level=1;
} elsif (s/^-h/-/) {
cmd_help();
} elsif (s/^-D/-/) {
@@ -1832,8 +1835,9 @@ if ($ENV{$fakeeditorenv}) {
delete $ENV{'DGET_UNPACK'};
parseopts();
-print STDERR "DRY RUN ONLY\n" if $dryrun > 1;
-print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n" if $dryrun == 1;
+print STDERR "DRY RUN ONLY\n" if $dryrun_level > 1;
+print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n"
+ if $dryrun_level == 1;
if (!@ARGV) {
print STDERR $helpmsg or die $!;
exit 8;