cvs: SVNROOT / post-commit pre-commit start-commit

[email protected] ("Gwynne Raskind") Sat, 20 Dec 2008 18:49:58 -0000
Newsgroups svn.migration
Message-ID <cvsgwynne1229798998@cvsserver>
gwynne		Sat Dec 20 18:49:58 2008 UTC

  Modified files:              
    /SVNROOT	post-commit pre-commit start-commit 
  Log:
  I'm so stupid, I'm so dumb, shoot me now. die() doesn't provide a non-zero exit code. Update to use fwrite() and exit(), and kill a useless var in the avail file
  
http://cvs.php.net/viewvc.cgi/SVNROOT/post-commit?r1=1.4&r2=1.5&diff_format=u
Index: SVNROOT/post-commit
diff -u SVNROOT/post-commit:1.4 SVNROOT/post-commit:1.5
--- SVNROOT/post-commit:1.4	Sat Dec 20 02:52:45 2008
+++ SVNROOT/post-commit	Sat Dec 20 18:49:58 2008
@@ -7,20 +7,26 @@
 date_default_timezone_set('UTC');
 putenv("PATH=/usr/local/bin");
 
+function fail($error)
+{
+    fwrite(STDERR, $error);
+    exit(1);
+}
+
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.4 $', strlen('$Revision: '), -2);
+$version = substr('$Revision: 1.5 $', strlen('$Revision: '), -2);
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Version check
 if (version_compare('5.2.0', PHP_VERSION, '>')) {
-    die("Requires at least PHP 5.2.\n");
+    fail("Requires at least PHP 5.2.\n");
 }
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Arguments
 if ($argc != 3) {
-    die("Pass exactly two arguments: REPOS and REV.\n");
+    fail("Pass exactly two arguments: REPOS and REV.\n");
 }
 $REPOS = $argv[1];
 $REV = $argv[2];
@@ -34,7 +40,7 @@
 {
     exec('exec svnlook ' . escapeshellarg($command) . ' -r ' . escapeshellarg($GLOBALS['REV']) . ' ' . escapeshellarg($GLOBALS['REPOS']), $output, $status);
     if ($status != 0) {
-        die("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
+        fail("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
     }
     return $output;
 }
@@ -67,7 +73,7 @@
     exec('exec svn update', $output, $status);
     print implode("\n", $output) . "\n";
     if ($status != 0) {
-        die("svn update on SVNROOT failed with exit code {$status}!\n");
+        fail("svn update on SVNROOT failed with exit code {$status}!\n");
     }
 }
 
http://cvs.php.net/viewvc.cgi/SVNROOT/pre-commit?r1=1.4&r2=1.5&diff_format=u
Index: SVNROOT/pre-commit
diff -u SVNROOT/pre-commit:1.4 SVNROOT/pre-commit:1.5
--- SVNROOT/pre-commit:1.4	Sat Dec 20 02:52:45 2008
+++ SVNROOT/pre-commit	Sat Dec 20 18:49:58 2008
@@ -7,20 +7,26 @@
 date_default_timezone_set('UTC');
 putenv("PATH=/usr/local/bin");
 
+function fail($error)
+{
+    fwrite(STDERR, $error);
+    exit(1);
+}
+
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.4 $', strlen('$Revision: '), -2);
+$version = substr('$Revision: 1.5 $', strlen('$Revision: '), -2);
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Version check
 if (version_compare('5.2.0', PHP_VERSION, '>')) {
-    die("Requires at least PHP 5.2.\n");
+    fail("Requires at least PHP 5.2.\n");
 }
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Arguments
 if ($argc != 3) {
-    die("Pass exactly two arguments: REPOS and TXN.\n");
+    fail("Pass exactly two arguments: REPOS and TXN.\n");
 }
 $REPOS = $argv[1];
 $TXN = $argv[2];
@@ -31,7 +37,7 @@
 {
     exec('exec svnlook ' . escapeshellarg($command) . ' -t ' . escapeshellarg($GLOBALS['TXN']) . ' ' . escapeshellarg($GLOBALS['REPOS']), $output, $status);
     if ($status != 0) {
-        die("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
+        fail("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
     }
     return $output;
 }
@@ -73,7 +79,7 @@
 // -----------------------------------------------------------------------------------------------------------------------------
 // Log message empty?
 if (strlen(trim(implode("\n", $log_message))) == 0) {
-    die("Please specify a log message.\n");
+    fail("Please specify a log message.\n");
 }
 
 // -----------------------------------------------------------------------------------------------------------------------------
@@ -87,7 +93,6 @@
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Check commit against it
-$universal_off = FALSE;
 $exit_val = 0;
 foreach ($dirs_changed as $dir_changed) {
     foreach ($avail_lines as $avail_line) {
@@ -101,9 +106,6 @@
 
         $params = explode("|", trim($avail_line));
         if (count($params) == 1) {  // avail/unavail by itself
-            if (!$bit) {
-                $universal_off = TRUE;
-            }
             $userlist = array();
             $modulelist = array();
         } else if (count($params) == 2) {   // user list but no mod list
@@ -147,7 +149,7 @@
 }
 
 if ($exit_val) {
-    die("Access denied: Insufficient karma for {$author} to {$last_dir}.\n");
+    fail("Access denied: Insufficient karma for {$author} to {$last_dir}.\n");
 }
 
 if (isset($_ENV['DEBUG']) && $_ENV['DEBUG'] == 'DEBUG') {
http://cvs.php.net/viewvc.cgi/SVNROOT/start-commit?r1=1.3&r2=1.4&diff_format=u
Index: SVNROOT/start-commit
diff -u SVNROOT/start-commit:1.3 SVNROOT/start-commit:1.4
--- SVNROOT/start-commit:1.3	Sat Dec 20 02:52:45 2008
+++ SVNROOT/start-commit	Sat Dec 20 18:49:58 2008
@@ -7,20 +7,26 @@
 date_default_timezone_set('UTC');
 putenv("PATH=/usr/local/bin");
 
+function fail($error)
+{
+    fwrite(STDERR, $error);
+    exit(1);
+}
+
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.3 $', strlen('$Revision: '), -2);
+$version = substr('$Revision: 1.4 $', strlen('$Revision: '), -2);
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Version check
 if (version_compare('5.2.0', PHP_VERSION, '>')) {
-    die("Requires at least PHP 5.2.\n");
+    fail("Requires at least PHP 5.2.\n");
 }
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Arguments
 if ($argc != 4) {
-    die("Pass exactly three arguments: REPOS, USER, and CAPABILITIES.\n");
+    fail("Pass exactly three arguments: REPOS, USER, and CAPABILITIES.\n");
 }
 $REPOS = $argv[1];
 $USER = $argv[2];
@@ -29,7 +35,7 @@
 // -----------------------------------------------------------------------------------------------------------------------------
 // Is the user svnread?
 if ($USER == 'svnread') {
-    die("svnread can not commit to the repository.\n");
+    fail("svnread can not commit to the repository.\n");
 }
 
 // -----------------------------------------------------------------------------------------------------------------------------
@@ -44,7 +50,7 @@
 }
 
 if (!$userexists) {
-    die("No such user.\n");
+    fail("No such user.\n");
 }
 
 // -----------------------------------------------------------------------------------------------------------------------------