chiark / gitweb /
Dgit.pm: runcmd: Break out from dgit
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 3 Feb 2017 21:54:56 +0000 (21:54 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 Jul 2017 21:08:43 +0000 (22:08 +0100)
Move runcmd into Dgit.pm.

We need to change dgit-repos-server too, but luckily its definition is
essentially equivalent.

No functional change to dgit.  dgit-repos-server now prints somewhat
better error messages when subprocesses fail.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm
dgit
infra/dgit-repos-server

index dcecbd1..5b5591d 100644 (file)
@@ -45,7 +45,7 @@ BEGIN {
                       fail ensuredir executable_on_path
                       waitstatusmsg failedcmd_waitstatus
                      failedcmd_report_cmd failedcmd
-                      cmdoutput cmdoutput_errok
+                      runcmd cmdoutput cmdoutput_errok
                       git_rev_parse git_cat_file
                      git_get_ref git_for_each_ref
                       git_for_each_tag_referring is_fast_fwd
@@ -276,6 +276,12 @@ sub failedcmd {
     fail failedcmd_waitstatus();
 }
 
+sub runcmd {
+    debugcmd "+",@_;
+    $!=0; $?=-1;
+    failedcmd @_ if system @_;
+}
+
 sub cmdoutput_errok {
     confess Dumper(\@_)." ?" if grep { !defined } @_;
     debugcmd "|",@_;
diff --git a/dgit b/dgit
index 9c7ec73..54ba4d6 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -493,12 +493,6 @@ sub url_get {
 
 our ($dscdata,$dscurl,$dsc,$dsc_checked,$skew_warning_vsn);
 
-sub runcmd {
-    debugcmd "+",@_;
-    $!=0; $?=-1;
-    failedcmd @_ if system @_;
-}
-
 sub act_local () { return $dryrun_level <= 1; }
 sub act_scary () { return !$dryrun_level; }
 
index ec9b2c9..a8b9400 100755 (executable)
@@ -303,13 +303,6 @@ sub reject ($) {
     die "\ndgit-repos-server: reject: $why\n\n";
 }
 
-sub runcmd {
-    debugcmd '+',@_;
-    $!=0; $?=0;
-    my $r = system @_;
-    die (shellquote @_)." $? $!" if $r;
-}
-
 sub policyhook {
     my ($policyallowbits, @polargs) = @_;
     # => ($exitstatuspolicybitmap);