gwynne Fri, 17 Jul 2009 12:39:24 +0000
URL: http://svn.php.net/viewvc?view=revision&revision=284257
Changed paths:
U SVNROOT/commit-email.php
Log:
significantly improve email subject handling. I hope. Also make the message ID
more useful.
Modified: SVNROOT/commit-email.php
===================================================================
--- SVNROOT/commit-email.php 2009-07-17 12:31:58 UTC (rev 284256)
+++ SVNROOT/commit-email.php 2009-07-17 12:39:24 UTC (rev 284257)
@@ -103,6 +103,19 @@
$always_addresses = array('[email protected]');
//
-----------------------------------------------------------------------------------------------------------------------------
+function common_prefix($str1, $str2)
+{
+ $result = "";
+ $i = 0;
+ $max = min(strlen($str1), strlen($str2));
+ while ($i < $max && $str1[$i] === $str2[$i]) {
+ $result .= $str1[$i];
+ ++$i;
+ }
+ return $result;
+}
+
+//
-----------------------------------------------------------------------------------------------------------------------------
// Get info from commit
$commit_info = run_svnlook('info');
$commit_user = trim($commit_info[0]);
@@ -144,11 +157,13 @@
break;
}
}
- if (substr_count($changed_path, '/') < substr_count($parent_path, '/')) {
- $parent_path = $changed_path;
+ if ($changed_path === '/') {
+ $parent_path = '';
+ } else {
+ $parent_path = common_prefix($parent_path, $changed_path);
}
}
-if (count($emails_to) == 0) {
+if (count($emails_to) === 0) {
$emails_to = $fallback_addresses;
}
$emails_to = array_merge($emails_to, $always_addresses);
@@ -165,12 +180,12 @@
//
-----------------------------------------------------------------------------------------------------------------------------
// Build e-mail
$boundary = sha1("{$commit_user}{$commit_date}");
-$messageid = "{$boundary}" . mt_rand();
-$subject = "svn: {$parent_path}";
+$messageid = "{$commit_user}-{$commit_date}-{$REV}-" . mt_rand();
+$subject = "svn: " . ($parent_path === '' ? '/' : $parent_path);
foreach ($changed_paths as $changed_path) {
$changed_path = trim(strstr($changed_path, ' '));
if (substr($changed_path, -1) !== '/') {
- $subject .= ' ' . substr($changed_path, $parent_path === '/' ? 0 :
strlen($parent_path));
+ $subject .= ' ' . substr($changed_path, strlen($parent_path));
}
}
$subject = substr($subject, 0, 950); // Max SMTP line length = 998. Some slop
in this value.
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php