]> git.pld-linux.org Git - packages/eventum.git/blob - eventum-svn.patch
- display email addresses to whom email was sent when issue was updated
[packages/eventum.git] / eventum-svn.patch
1 --- eventum-20060724/misc/scm/process_svn_commits.php   2006-07-25 00:34:44.884132544 +0300
2 +++ eventum-20060724.svn/misc/scm/process_svn_commits.php       2006-07-25 00:34:07.543295681 +0300
3 @@ -25,28 +25,44 @@
4  // | Authors: João Prado Maia <jpm@mysql.com>                             |
5  // |          Adam Ratcliffe <adam.ratcliffe@geosmart.co.nz>              |
6  // |          Frederik M. Kraus <f.kraus@pangora.com>                     |
7 +// |          Elan Ruusamäe <glen@delfi.ee>                               |
8  // +----------------------------------------------------------------------+
9  //
10  // @(#) $Id$
11  //
12 +// See http://eventum.mysql.org/wiki/index.php/Subversion_integration about SVN integration.
13  
14 -$eventum_domain = 'www.geosmartlbs.co.nz';
15 -$eventum_relative_url = '/eventum/';
16 -$eventum_port = 80;
17 -$svnlook = '/usr/bin/svnlook';
18 -$separatorChar = "/";
19 +include '/etc/eventum/scm.php';
20  
21  //
22  // DO NOT CHANGE ANYTHING AFTER THIS LINE
23  //
24  
25 -if(!file_exists($svnlook)) {
26 -    echo 'svnlook does not exist, edit $svnlook\n';
27 -    exit(1);
28 +if (isset($eventum_url)) {
29 +    $data = parse_url($eventum_url);
30 +} else {
31 +    // legacy
32 +    $data = array();
33 +    $data['host'] = $eventum_domain;
34 +    $data['path'] = $eventum_relative_url;
35 +    $data['port'] = $eventum_port;
36 +    $data['scheme'] = 'http';
37 +}
38 +
39 +if (!isset($data['port'])) {
40 +    $data['port'] = $data['scheme'] == 'https' ? 443 : 80;
41 +}
42 +
43 +if (!isset($svnlook)) {
44 +    $svnlook = '/usr/bin/svnlook';
45 +}
46 +
47 +if (!is_executable($svnlook)) {
48 +    die('svnlook is not executable, edit $svnlook');
49  }
50  
51 -if(count($argv) < 3) {
52 -    echo 'missing arguments, got ' . count($argv) . ' expected 3\n';
53 +if ($argc < 3) {
54 +    printf("Missing arguments, got %d, expected 2\n", $argc - 1);
55      exit(1);
56  }
57  
58 @@ -54,19 +70,16 @@
59  $rev = $argv[2];
60  $oldRev = $rev - 1;
61  
62 -$svn_module = base64_encode(substr(strrchr($repos, $separatorChar), 1));
63 +$scm_module = rawurlencode(basename($repos));
64  
65  $results = array();
66  exec($svnlook . ' info ' . $repos . ' -r ' . $rev, $results);
67  
68 -$username = base64_encode(array_shift($results));
69 +$username = array_shift($results);
70  $date = array_shift($results);
71  array_shift($results); // ignore file length
72  
73 -$commit_msg = '';
74 -foreach ($results as $line) {
75 -    $commit_msg .= $line."\n";
76 -}
77 +$commit_msg = join("\n", $results);
78  // now we have to strip html-tags from the commit message
79  $commit_msg = strip_tags($commit_msg);
80  
81 @@ -76,48 +89,52 @@
82      $pieces = explode('   ', $file_info);
83      $filename = $pieces[1];
84      $modified_files[] = array(
85 -    'filename'     => "/" . $filename,
86 -    'old_revision' => $oldRev,
87 -    'new_revision' => $rev
88 +        'filename'     => $filename,
89 +        'old_revision' => $oldRev,
90 +        'new_revision' => $rev
91      );
92  }
93  
94  // parse the commit message and get all issue numbers we can find
95 -$pattern = "/[issue|bug] ?:? ?#?(\d+)/i";
96 +$pattern = "/(?:issue|bug) ?:? ?#?(\d+)/i";
97  preg_match_all($pattern, $commit_msg, $matches);
98  
99 -if (count($matches) == 2 && count($matches[1]) > 0) {
100 -    $commit_msg = base64_encode($commit_msg);
101 -    foreach ($matches[0] as $p_issue_id) {
102 -        echo "Matched ISSUE #".$p_issue_id."\n";
103 -        $issue_id = base64_encode($p_issue_id);
104 -        // build the GET url to use
105 -        $ping_url = $eventum_relative_url .
106 -                    "scm_ping.php?module=$svn_module&username=$username&commit_msg=$commit_msg";
107 +if (count($matches) > 1) {
108 +    // need to encode all of the url arguments
109 +    $commit_msg = rawurlencode($commit_msg);
110 +    $scm_module = rawurlencode($scm_module);
111 +    $username = rawurlencode($username);
112 +
113 +    // build the GET url to use
114 +    $ping_url = $data['path']. "scm_ping.php?module=$scm_module&username=$username&commit_msg=$commit_msg";
115 +    foreach ($matches[1] as $issue_id) {
116 +        echo 'Matched Issue #', $issue_id, "\n";
117          $ping_url .= "&issue[]=$issue_id";
118 -        for ($i = 0; $i < count($modified_files); $i++) {
119 -            $ping_url .= "&files[$i]=" . base64_encode($modified_files[$i]['filename']);
120 -            $ping_url .= "&old_versions[$i]=" .
121 -                         base64_encode($modified_files[$i]['old_revision']);
122 -            $ping_url .= "&new_versions[$i]=" .
123 -                         base64_encode($modified_files[$i]['new_revision']);
124 -        }
125 +    }
126  
127 -        $fp = fsockopen($eventum_domain, $eventum_port, $errno, $errstr, 30);
128 +    for ($i = 0; $i < count($modified_files); $i++) {
129 +        $ping_url .= "&files[$i]=" . rawurlencode($modified_files[$i]['filename']);
130 +        $ping_url .= "&old_versions[$i]=" . rawurlencode($modified_files[$i]['old_revision']);
131 +        $ping_url .= "&new_versions[$i]=" . rawurlencode($modified_files[$i]['new_revision']);
132 +    }
133  
134 -        if (!$fp) {
135 -            echo "Error: Could not ping the Eventum SCM handler script.\n";
136 -            exit();
137 -        } else {
138 -            $msg = "GET $ping_url HTTP/1.1\r\n";
139 -            $msg .= "Host: $eventum_domain\r\n";
140 -            $msg .= "Connection: Close\r\n\r\n";
141 -            fwrite($fp, $msg);
142 -            fclose($fp);
143 +    $address = $data['host'];
144 +    if ($data['scheme'] == 'https') {
145 +        $address = "ssl://$address";
146 +    }
147 +    $fp = fsockopen($address, $data['port'], $errno, $errstr, 30);
148 +    if (!$fp) {
149 +        die("Error: Could not ping the Eventum SCM handler script.\n");
150 +    } else {
151 +        $msg = "GET $ping_url HTTP/1.1\r\n";
152 +        $msg .= "Host: $data[host]\r\n";
153 +        $msg .= "Connection: Close\r\n\r\n";
154 +        fwrite($fp, $msg);
155 +        $buf = fgets($fp, 4096);
156 +        list($proto, $status, $msg) = explode(' ', trim($buf), 3);
157 +        if ($status != '200') {
158 +            echo "Error: Could not ping the Eventum SCM handler script: HTTP status code: $status $msg\n";
159          }
160 +        fclose($fp);
161      }
162 -} else {
163 -    echo "No Match found\n";
164  }
165 -
166 -?>
This page took 0.05444 seconds and 3 git commands to generate.