cvs: SVNROOT / commit-email.php post-commit run-conversion.php

[email protected] ("Gwynne Raskind")
Newsgroups svn.migration
Message-ID <cvsgwynne1229055625@cvsserver>
gwynne		Fri Dec 12 04:20:25 2008 UTC

  Added files:                 
    /SVNROOT	post-commit 

  Modified files:              
    /SVNROOT	commit-email.php run-conversion.php 
  Log:
  add post-commit as a separate file to update SVNROOT as necessary, commit-email should contain email to addresses and is called from post-commit
gwynne-20081212042025.txt (text/plain, 9.2 KB)
http://cvs.php.net/viewvc.cgi/SVNROOT/commit-email.php?r1=1.3&r2=1.4&diff_format=u
Index: SVNROOT/commit-email.php
diff -u SVNROOT/commit-email.php:1.3 SVNROOT/commit-email.php:1.4
--- SVNROOT/commit-email.php:1.3	Mon Dec  8 21:01:22 2008
+++ SVNROOT/commit-email.php	Fri Dec 12 04:20:25 2008
@@ -1,41 +1,100 @@
 #!/usr/local/bin/php
 <?php
 
-// -----------------------------------------------------------------------------------------------------------------------------
-// Settings
-error_reporting(E_ALL | E_STRICT);
-date_default_timezone_set('UTC');
+// Note that this script is intended to be called from inside the post-commit
+// hook. It makes some assumptions: $REPOS and $REV are defined, the
+// run_svnlook() function is declared, $changed_paths and $dirs_changed are
+// determined.
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.3 $', strlen('$Revision: '), -2);
-$email_to = array('[email protected]');
+$version = substr('$Revision: 1.4 $', strlen('$Revision: '), -2);
 $smtp_server = '127.0.0.1';
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Version check
-if (version_compare('5.2.0', PHP_VERSION, '>')) {
-    die("Requires at least PHP 5.2.\n");
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Arguments
-if ($argc != 3) {
-    die("Pass exactly two arguments: REPOS and REV.\n");
-}
-$REPOS = $argv[1];
-$REV = $argv[2];
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Utility
-function run_svnlook($command)
-{
-    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");
-    }
-    return $output;
-}
+$commit_email_list = array(
+    // FastCGI ISAPI
+    '|^php/fastcgi-isapi|' => array('[email protected]', '[email protected]', '[email protected]'),
+    
+    // GTK
+    '|^gtk/php-gtk-web|' => array('[email protected]'),
+    '|^gtk/php-gtk-doc|' => array('[email protected]'),
+    '|^gtk/php-gtk|' => array('[email protected]'),
+    
+    // Web
+    '|^web/bugtracker|' => array('[email protected]'),
+    '|^web/presentations|' => array('[email protected]'),
+    '|^web/pres2|' => array('[email protected]'),
+    '|^web/php-|' => array('[email protected]'),
+    
+    // Zend/TSRM
+    '|^php/ZendAPI|' => array('[email protected]', '[email protected]'),
+    '|^php/php-src/ZendEngine2|' => array('[email protected]'),
+    '|^php/php-src/TSRM|' => array('[email protected]'),
+    
+    // phpdoc
+    '|^phpdoc/doc-base|' => array('[email protected]'),
+	'|^phpdoc/ar|' => array('[email protected]'),
+	'|^phpdoc/bg|' => array('[email protected]'),
+	'|^phpdoc/ca|' => array('[email protected]'),
+	'|^phpdoc/cs|' => array('[email protected]'),
+	'|^phpdoc/da|' => array('[email protected]'),
+	'|^phpdoc/de|' => array('[email protected]'),
+	'|^phpdoc/el|' => array('[email protected]'),
+	'|^phpdoc/es|' => array('[email protected]'),
+	'|^phpdoc/fa|' => array('[email protected]'),
+	'|^phpdoc/fi|' => array('[email protected]'),
+	'|^phpdoc/fr|' => array('[email protected]'),
+	'|^phpdoc/he|' => array('[email protected]'),
+	'|^phpdoc/hk|' => array('[email protected]'),
+	'|^phpdoc/hu|' => array('[email protected]'),
+	'|^phpdoc/id|' => array('[email protected]'),
+	'|^phpdoc/it|' => array('[email protected]'),
+	'|^phpdoc/ja|' => array('[email protected]'),
+	'|^phpdoc/kr|' => array('[email protected]'),
+	'|^phpdoc/lt|' => array('[email protected]'),
+	'|^phpdoc/nl|' => array('[email protected]'),
+	'|^phpdoc/no|' => array('[email protected]'),
+	'|^phpdoc/pl|' => array('[email protected]'),
+    '|^phpdoc/pt_BR|' => array('[email protected]'),
+	'|^phpdoc/pt|' => array('[email protected]'),
+	'|^phpdoc/ro|' => array('[email protected]'),
+	'|^phpdoc/ru|' => array('[email protected]'),
+	'|^phpdoc/sk|' => array('[email protected]'),
+	'|^phpdoc/sl|' => array('[email protected]'),
+	'|^phpdoc/sv|' => array('[email protected]'),
+	'|^phpdoc/tr|' => array('[email protected]'),
+	'|^phpdoc/tw|' => array('[email protected]'),
+	'|^phpdoc/zh|' => array('[email protected]'),
+    '|^phd|' => array('[email protected]'),
+    '|^web/doc|' => array('[email protected]'),
+
+    // PEAR
+    '|^pear/pearbot|' => array('[email protected]'),
+    '|^pear/peardoc/en/pecl|' => array('[email protected]', '[email protected]'),
+    '|^pear/peardoc|' => array('[email protected]'),
+    '|^pear/pear-core|' => array('[email protected]', '[email protected]'),
+    '|^pear/modules/installphars|' => array('[email protected]'),
+    '|^pear/modules|' => array('[email protected]'),
+    
+    // PECL
+    '|^php-src/pecl|' => array('[email protected]'),
+    
+    // QA-web
+    '|^web/qa|' => array('[email protected]'),
+    
+    // GD
+    '|^gd|' => array('[email protected]'),
+    
+    // Misc
+    '|^php/php-lang|' => array('[email protected]'),
+    '|^web/embed|' => array('[email protected]'),
+    '|^php/php-objc|' => array('[email protected]'),
+    
+    // Internals
+    '|^systems|' => array('[email protected]'),
+    '|^SVNROOT|' => array('[email protected]'),
+    
+    '|^.|' => array('[email protected]')
+);
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Get info from commit
@@ -50,8 +109,21 @@
 $from = '[email protected]';
 
 // -----------------------------------------------------------------------------------------------------------------------------
-// Build list of changes
-$changed_paths = run_svnlook('changed');
+// Build list of e-mail addresses and parent changed path
+$emails_to = array();
+$parent_path = $dirs_changed[0];
+
+foreach ($dirs_changed as $changed_path) {
+    foreach ($commit_email_list as $regex => $email_list) {
+        if (preg_match($regex, $changed_path, $matches) === 1) {
+            $emails_to = array_merge($emails_to, $email_list);
+        }
+    }
+    if (strlen($changed_path) < strlen($parent_path)) {
+        $parent_path = $changed_path;
+    }
+}
+$emails_to = array_unique($emails_to);
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Get diffs
@@ -59,19 +131,9 @@
 $diffs = implode("\n", $diffs);
 
 // -----------------------------------------------------------------------------------------------------------------------------
-// Parent changed path
-$dirs_changed = run_svnlook('dirs-changed');
-$parent_path = $dirs_changed[0];
-foreach ($dirs_changed as $dir_changed) {
-    if (strlen($dir_changed) < strlen($parent_path)) {
-        $parent_path = $dir_changed;
-    }
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
 // Build e-mail
 $msg_headers = "From: {$from}\n" .
-               "To: " . implode(', ', $email_to) . "\n" .
+               "To: " . implode(', ', $emails_to) . "\n" .
                "Message-ID: <svn{$commit_user}{$commit_date}@svn.php.net>\n" .
                "Date: " . date(DATE_RFC822, $commit_date) . "\n" .
                "Subject: svn: {$parent_path}\n";
@@ -120,7 +182,7 @@
 fwrite($socket,
     "HELO svnserver\r\n" .
     "MAIL FROM:<[email protected]>\r\n");
-foreach ($email_to as $send_addr) {
+foreach ($emails_to as $send_addr) {
     fwrite($socket, "RCPT TO:<{$send_addr}>\r\n");
 }
 fwrite($socket,
@@ -130,8 +192,4 @@
     "QUIT\r\n");
 fclose($socket);
 
-// -----------------------------------------------------------------------------------------------------------------------------
-// Done!
-exit(0);
-
 ?>
http://cvs.php.net/viewvc.cgi/SVNROOT/run-conversion.php?r1=1.56&r2=1.57&diff_format=u
Index: SVNROOT/run-conversion.php
diff -u SVNROOT/run-conversion.php:1.56 SVNROOT/run-conversion.php:1.57
--- SVNROOT/run-conversion.php:1.56	Mon Dec  8 18:52:28 2008
+++ SVNROOT/run-conversion.php	Fri Dec 12 04:20:25 2008
@@ -7,7 +7,7 @@
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.56 $', strlen('$Revision: '), -2);
+$version = substr('$Revision: 1.57 $', strlen('$Revision: '), -2);
 
 $passes = array(
     'processcvs',       // Process CVS modules
@@ -516,7 +516,7 @@
 
     v(2, "Installing post-commit hook...\n");
     @unlink("{$svnPath}/repository/hooks/post-commit");
-    symlink("{$svnPath}/SVNROOT/commit-email.php", "{$svnPath}/repository/hooks/post-commit");
+    symlink("{$svnPath}/SVNROOT/post-commit", "{$svnPath}/repository/hooks/post-commit");
 
     v(1, "Done installing global administrative files.\n");
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.