SOURCES: eventum-svn.patch (NEW) - svn integration script fixes

glen glen at pld-linux.org
Tue Jul 25 00:37:05 CEST 2006


Author: glen                         Date: Mon Jul 24 22:37:04 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- svn integration script fixes

---- Files affected:
SOURCES:
   eventum-svn.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/eventum-svn.patch
diff -u /dev/null SOURCES/eventum-svn.patch:1.1
--- /dev/null	Tue Jul 25 00:37:04 2006
+++ SOURCES/eventum-svn.patch	Tue Jul 25 00:36:59 2006
@@ -0,0 +1,166 @@
+--- eventum-20060724/misc/scm/process_svn_commits.php	2006-07-25 00:34:44.884132544 +0300
++++ eventum-20060724.svn/misc/scm/process_svn_commits.php	2006-07-25 00:34:07.543295681 +0300
+@@ -25,28 +25,44 @@
+ // | Authors: Joăo Prado Maia <jpm at mysql.com>                             |
+ // |          Adam Ratcliffe <adam.ratcliffe at geosmart.co.nz>              |
+ // |          Frederik M. Kraus <f.kraus at pangora.com>                     |
++// |          Elan Ruusamäe <glen at delfi.ee>                               |
+ // +----------------------------------------------------------------------+
+ //
+ // @(#) $Id$
+ //
++// See http://eventum.mysql.org/wiki/index.php/Subversion_integration about SVN integration.
+ 
+-$eventum_domain = 'www.geosmartlbs.co.nz';
+-$eventum_relative_url = '/eventum/';
+-$eventum_port = 80;
+-$svnlook = '/usr/bin/svnlook';
+-$separatorChar = "/";
++include '/etc/eventum/scm.php';
+ 
+ //
+ // DO NOT CHANGE ANYTHING AFTER THIS LINE
+ //
+ 
+-if(!file_exists($svnlook)) {
+-    echo 'svnlook does not exist, edit $svnlook\n';
+-    exit(1);
++if (isset($eventum_url)) {
++    $data = parse_url($eventum_url);
++} else {
++    // legacy
++    $data = array();
++    $data['host'] = $eventum_domain;
++    $data['path'] = $eventum_relative_url;
++    $data['port'] = $eventum_port;
++    $data['scheme'] = 'http';
++}
++
++if (!isset($data['port'])) {
++    $data['port'] = $data['scheme'] == 'https' ? 443 : 80;
++}
++
++if (!isset($svnlook)) {
++    $svnlook = '/usr/bin/svnlook';
++}
++
++if (!is_executable($svnlook)) {
++    die('svnlook is not executable, edit $svnlook');
+ }
+ 
+-if(count($argv) < 3) {
+-    echo 'missing arguments, got ' . count($argv) . ' expected 3\n';
++if ($argc < 3) {
++    printf("Missing arguments, got %d, expected 2\n", $argc - 1);
+     exit(1);
+ }
+ 
+@@ -54,19 +70,16 @@
+ $rev = $argv[2];
+ $oldRev = $rev - 1;
+ 
+-$svn_module = base64_encode(substr(strrchr($repos, $separatorChar), 1));
++$scm_module = rawurlencode(basename($repos));
+ 
+ $results = array();
+ exec($svnlook . ' info ' . $repos . ' -r ' . $rev, $results);
+ 
+-$username = base64_encode(array_shift($results));
++$username = array_shift($results);
+ $date = array_shift($results);
+ array_shift($results); // ignore file length
+ 
+-$commit_msg = '';
+-foreach ($results as $line) {
+-    $commit_msg .= $line."\n";
+-}
++$commit_msg = join("\n", $results);
+ // now we have to strip html-tags from the commit message
+ $commit_msg = strip_tags($commit_msg);
+ 
+@@ -76,48 +89,52 @@
+     $pieces = explode('   ', $file_info);
+     $filename = $pieces[1];
+     $modified_files[] = array(
+-    'filename'     => "/" . $filename,
+-    'old_revision' => $oldRev,
+-    'new_revision' => $rev
++        'filename'     => $filename,
++        'old_revision' => $oldRev,
++        'new_revision' => $rev
+     );
+ }
+ 
+ // parse the commit message and get all issue numbers we can find
+-$pattern = "/[issue|bug] ?:? ?#?(\d+)/i";
++$pattern = "/(?:issue|bug) ?:? ?#?(\d+)/i";
+ preg_match_all($pattern, $commit_msg, $matches);
+ 
+-if (count($matches) == 2 && count($matches[1]) > 0) {
+-    $commit_msg = base64_encode($commit_msg);
+-    foreach ($matches[0] as $p_issue_id) {
+-        echo "Matched ISSUE #".$p_issue_id."\n";
+-        $issue_id = base64_encode($p_issue_id);
+-        // build the GET url to use
+-        $ping_url = $eventum_relative_url .
+-                    "scm_ping.php?module=$svn_module&username=$username&commit_msg=$commit_msg";
++if (count($matches) > 1) {
++    // need to encode all of the url arguments
++    $commit_msg = rawurlencode($commit_msg);
++    $scm_module = rawurlencode($scm_module);
++    $username = rawurlencode($username);
++
++    // build the GET url to use
++    $ping_url = $data['path']. "scm_ping.php?module=$scm_module&username=$username&commit_msg=$commit_msg";
++    foreach ($matches[1] as $issue_id) {
++        echo 'Matched Issue #', $issue_id, "\n";
+         $ping_url .= "&issue[]=$issue_id";
+-        for ($i = 0; $i < count($modified_files); $i++) {
+-            $ping_url .= "&files[$i]=" . base64_encode($modified_files[$i]['filename']);
+-            $ping_url .= "&old_versions[$i]=" .
+-                         base64_encode($modified_files[$i]['old_revision']);
+-            $ping_url .= "&new_versions[$i]=" .
+-                         base64_encode($modified_files[$i]['new_revision']);
+-        }
++    }
+ 
+-        $fp = fsockopen($eventum_domain, $eventum_port, $errno, $errstr, 30);
++    for ($i = 0; $i < count($modified_files); $i++) {
++        $ping_url .= "&files[$i]=" . rawurlencode($modified_files[$i]['filename']);
++        $ping_url .= "&old_versions[$i]=" . rawurlencode($modified_files[$i]['old_revision']);
++        $ping_url .= "&new_versions[$i]=" . rawurlencode($modified_files[$i]['new_revision']);
++    }
+ 
+-        if (!$fp) {
+-            echo "Error: Could not ping the Eventum SCM handler script.\n";
+-            exit();
+-        } else {
+-            $msg = "GET $ping_url HTTP/1.1\r\n";
+-            $msg .= "Host: $eventum_domain\r\n";
+-            $msg .= "Connection: Close\r\n\r\n";
+-            fwrite($fp, $msg);
+-            fclose($fp);
++    $address = $data['host'];
++    if ($data['scheme'] == 'https') {
++        $address = "ssl://$address";
++    }
++    $fp = fsockopen($address, $data['port'], $errno, $errstr, 30);
++    if (!$fp) {
++        die("Error: Could not ping the Eventum SCM handler script.\n");
++    } else {
++        $msg = "GET $ping_url HTTP/1.1\r\n";
++        $msg .= "Host: $data[host]\r\n";
++        $msg .= "Connection: Close\r\n\r\n";
++        fwrite($fp, $msg);
++        $buf = fgets($fp, 4096);
++        list($proto, $status, $msg) = explode(' ', trim($buf));
++        if ($status != '200') {
++            echo "Error: Could not ping the Eventum SCM handler script: HTTP status code: $status $msg\n";
+         }
++        fclose($fp);
+     }
+-} else {
+-    echo "No Match found\n";
+ }
+-
+-?>
================================================================


More information about the pld-cvs-commit mailing list