gwynne Fri, 24 Jul 2009 18:54:54 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=284714
Log:
- Restructure hooks again. They now use a common include which does a bunch of
common stuff.
- Use PHP_EOL instead of a literal \n for commit emails. Paranoia.
- Now provide more information on copied paths (esp. for tagging)
- Creating tags by copying an existing directory is now allowed
- start-commit doesn't need to do anything
- reduce the number of times the path list is iterated in pre-commit
- Now mix and match the use of global and pear avail files on a per-path basis
- TODO: Parse the avail files only once instead of once per committed path
- Replace regexp with simple string ops for just about everything
- Don't bother storing the URL prefix as part of the bug info, nothing used that
- Remove worthless $Revision$ constants. Another thing nothing used.
Changed paths:
U SVNROOT/commit-bugs.php
U SVNROOT/commit-email.php
U SVNROOT/commit-svnroot.php
A SVNROOT/hook-common.inc.php
U SVNROOT/post-commit
U SVNROOT/pre-commit
U SVNROOT/start-commit
Modified: SVNROOT/commit-bugs.php
===================================================================
--- SVNROOT/commit-bugs.php 2009-07-24 18:08:42 UTC (rev 284713)
+++ SVNROOT/commit-bugs.php 2009-07-24 18:54:54 UTC (rev 284714)
@@ -5,7 +5,6 @@
// -----------------------------------------------------------------------------------------------------------------------------
// Constants
-$version = substr('$Revision$', strlen('$Revision: '), -2);
$bug_pattern = '/(?:(pecl|pear|php)\s*)?(?:bug|#)[\s#:]*([0-9]+)/iuX';
$bug_url_prefixes = array(
'pear' => 'http://pear.php.net/bugs',
@@ -45,8 +44,8 @@
$bug['project'] = $matched_bug[1] === "" ? $bug_project_default : strtolower($matched_bug[1]);
$bug['number'] = intval($matched_bug[2]);
$bugid = $bug['project'] . $bug['number'];
- $bug['url_prefix'] = isset($bug_url_prefixes[$bug['project']]) ? $bug_url_prefixes[$bug['project']] : $bug_url_prefixes[''];
- $bug['url'] = $bug['url_prefix'] . '/' . $bug['number'];
+ $url_prefix = isset($bug_url_prefixes[$bug['project']]) ? $bug_url_prefixes[$bug['project']] : $bug_url_prefixes[''];
+ $bug['url'] = $url_prefix . '/' . $bug['number'];
$bug['status'] = 'unknown';
$bug['short_desc'] = '';
$bug_list[$bugid] = $bug;
Modified: SVNROOT/commit-email.php
===================================================================
--- SVNROOT/commit-email.php 2009-07-24 18:08:42 UTC (rev 284713)
+++ SVNROOT/commit-email.php 2009-07-24 18:54:54 UTC (rev 284714)
@@ -5,7 +5,6 @@
// -----------------------------------------------------------------------------------------------------------------------------
// Constants
-$version = substr('$Revision$', strlen('$Revision: '), -2);
$smtp_server = '127.0.0.1';
$commit_email_list = array(
@@ -103,19 +102,6 @@
$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;
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
// Build list of e-mail addresses and parent changed path
$emails_to = array();
$parent_path = '/' . $commit_info['dirs_changed'][0];
@@ -150,22 +136,21 @@
// Process bugs
$bugs_body = '';
if (isset($bug_list) && count($bug_list) > 0) {
- $bugs_body = count($bug_list) > 1 ? "\nBugs: " : "\nBug: ";
+ $bugs_body = PHP_EOL . (count($bug_list) > 1 ? "Bugs: " : "Bug: ");
foreach ($bug_list as $n => $bug) {
if (isset($bug['error'])) {
$status = '(error getting bug information)';
} else {
$status = "({$bug['status']}) {$bug['short_desc']}";
}
- $bugs_body .= "{$bug['url']} {$status}\n ";
+ $bugs_body .= "{$bug['url']} {$status}" . PHP_EOL . " ";
}
}
// -----------------------------------------------------------------------------------------------------------------------------
// Process changed paths
$paths_list = $parent_path;
-foreach ($commit_info['changed_paths'] as $changed_path) {
- $changed_path = trim(strstr($changed_path, ' '));
+foreach ($commit_info['changed_paths'] as $changed_path => $path_actions) {
if (substr($changed_path, -1) !== '/') {
$paths_list .= ' ' . substr($changed_path, strlen($parent_path) - 1);
}
@@ -179,13 +164,13 @@
$email_date = date(DATE_RFC2822, $commit_info['date']);
$fullname = "=?utf-8?q?" . imap_8bit(str_replace(array('?', ' '), array('=3F', '_'), $commit_info['author_name'])) . "?=";
$email_list = implode(', ', $emails_to);
-$readable_path_list = " " . implode("\n ", $commit_info['changed_paths']);
+$readable_path_list = " " . implode(PHP_EOL . " ", $commit_info['raw_changed_paths']);
$nspaces = str_repeat(" ", max(1, 72 - strlen($commit_info['author']) - strlen($email_date)));
$msg_body = <<<MIMEBODY
From: {$fullname} <{$commit_info['author'][email protected]>
To: {$email_list}
-Message-ID: <svn{[email protected]>
+Message-ID: <svn-{[email protected]>
Date: {$email_date}
Subject: {$subject}
MIME-Version: 1.0
@@ -210,7 +195,7 @@
MIMEBODY;
if ($diffs_string === NULL) {
- $diff_data = wordwrap(base64_encode($commit_info['diffs']), 80, "\n", TRUE);
+ $diff_data = wordwrap(base64_encode($commit_info['diffs']), 80, PHP_EOL, TRUE);
$msg_body .= <<<MIMEBODY
Content-Type: text/x-diff; encoding="utf-8"
Modified: SVNROOT/commit-svnroot.php
===================================================================
--- SVNROOT/commit-svnroot.php 2009-07-24 18:08:42 UTC (rev 284713)
+++ SVNROOT/commit-svnroot.php 2009-07-24 18:54:54 UTC (rev 284714)
@@ -4,10 +4,6 @@
// the appropriate variables and functions are defined.
// -----------------------------------------------------------------------------------------------------------------------------
-// Constants
-$version = substr('$Revision$', strlen('$Revision: '), -2);
-
-// -----------------------------------------------------------------------------------------------------------------------------
// Check for a SVNROOT commit
$SVNROOT_changed = FALSE;
foreach ($commit_info['dirs_changed'] as $changed_path) {
@@ -20,9 +16,7 @@
// -----------------------------------------------------------------------------------------------------------------------------
// If SVNROOT had a commit, we need to update the admin copy
if ($SVNROOT_changed) {
- if ($is_DEBUG) {
- print "Updating SVNROOT...\n";
- }
+ debug("Updating SVNROOT...");
chdir(__DIR__);
exec('exec svn update', $output, $status);
fwrite(STDERR, implode("\n", $output) . "\n");
Added: SVNROOT/hook-common.inc.php
===================================================================
--- SVNROOT/hook-common.inc.php (rev 0)
+++ SVNROOT/hook-common.inc.php 2009-07-24 18:54:54 UTC (rev 284714)
@@ -0,0 +1,144 @@
+<?php
+
+// -----------------------------------------------------------------------------------------------------------------------------
+// Settings
+error_reporting(E_ALL | E_STRICT);
+date_default_timezone_set('UTC');
+putenv("PATH=/usr/local/bin:/usr/bin:/bin");
+
+function fail($error)
+{
+ fwrite(STDERR, $error);
+ exit(1);
+}
+
+// -----------------------------------------------------------------------------------------------------------------------------
+// Constants
+$is_DEBUG = (isset($_ENV['DEBUG']) && $_ENV['DEBUG'] === 'DEBUG');
+
+// -----------------------------------------------------------------------------------------------------------------------------
+// Version check
+if (version_compare('5.2.0', PHP_VERSION, '>')) {
+ fail("Requires at least PHP 5.2.\n");
+}
+if (!defined('__DIR__')) {
+ define('__DIR__', dirname(__FILE__));
+}
+
+// -----------------------------------------------------------------------------------------------------------------------------
+// Utility functions
+function run_svnlook($command, $flags = array(), $args = array())
+{
+ if (isset($GLOBALS['TXN'])) {
+ $selector = '-t';
+ $selectee = $GLOBALS['TXN'];
+ } else if (isset($GLOBALS['REV'])) {
+ $selector = '-r';
+ $selectee = $GLOBALS['REV'];
+ } else {
+ fail("Unknown hook.\n");
+ }
+
+ $args = implode(' ', array_map('escapeshellarg', array_merge(
+ array('svnlook', $command),
+ $flags,
+ array($selector, $selectee, $GLOBALS['REPOS']),
+ $args
+ )));
+ exec("exec {$args} 2>&1", $output, $status);
+ if ($status !== 0) {
+ fail("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
+ }
+ return $output;
+}
+
+function process_changed_paths($path_list)
+{
+ static $action_types = array('A' => 'added', 'D' => 'removed', 'U' => 'changed');
+ $final_paths = array();
+ for ($i = 0; $i < count($path_list); ++$i) {
+ $changed_path = $path_list[$i];
+ $content_status = $changed_path[0];
+ $props_status = $changed_path[1];
+ $copy_status = $changed_path[2];
+ $actual_path = substr($changed_path, 4);
+ $path_actions = array();
+ if ($content_status !== ' ' && $content_status !== '_') {
+ $path_actions[] = $action_types[$content_status];
+ }
+ if ($props_status !== ' ') {
+ $path_actions[] = 'props-changed';
+ }
+ if ($copy_status === '+') {
+ $path_actions[] = 'copied';
+ ++$i;
+ }
+ $final_paths[$actual_path] = $path_actions;
+ }
+ debug(print_r($final_paths, 1));
+ return $final_paths;
+}
+
+function read_commit_information()
+{
+ global $is_DEBUG;
+
+ $info = array(
+ 'raw_changed_paths' => run_svnlook('changed', array('--copy-info')),
+ 'dirs_changed' => run_svnlook('dirs-changed'),
+ 'author' => ($is_DEBUG && getenv("DEBUGUSER")) ? getenv("DEBUGUSER") : trim(implode('', run_svnlook('author'))),
+ 'log_message' => trim(implode("\n", run_svnlook('log'))),
+ 'date' => strtotime(substr(trim(implode('', run_svnlook('date'))), 0, strlen("0000-00-00 00:00:00 +0000"))),
+ 'diffs' => implode("\n", run_svnlook('diff')),
+ );
+
+ $info['changed_paths'] = process_changed_paths($info['raw_changed_paths']);
+
+ list($info['author_name'], $info['author_email']) = find_user($info['author']);
+
+ return $info;
+}
+
+function find_user($author)
+{
+ $usersDB = file(__DIR__ . '/users.db');
+ $saw_last_ISO = FALSE;
+ foreach ($usersDB as $userline) {
+ list ($username, $fullname, $email) = explode(":", trim($userline));
+ if ($username === 'ladderalice') {
+ $saw_last_ISO = TRUE;
+ }
+ if ($username === $author) {
+ if ($saw_last_ISO !== TRUE) {
+ $fullname = iconv("ISO-8859-1", "UTF-8//TRANSLIT", $fullname);
+ }
+ $result = array($fullname, $email);
+ break;
+ }
+ }
+ if (!isset($result)) {
+ fail("No such user.\n");
+ }
+ return $result;
+}
+
+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;
+}
+
+function debug($message)
+{
+ if ($GLOBALS['is_DEBUG']) {
+ print "DEBUG: {$message}\n";
+ }
+}
+
+?>
Property changes on: SVNROOT/hook-common.inc.php
___________________________________________________________________
Added: svn:keywords
+ Id Rev
Added: svn:eol-style
+ native
Modified: SVNROOT/post-commit
===================================================================
--- SVNROOT/post-commit 2009-07-24 18:08:42 UTC (rev 284713)
+++ SVNROOT/post-commit 2009-07-24 18:54:54 UTC (rev 284714)
@@ -2,32 +2,10 @@
<?php
// -----------------------------------------------------------------------------------------------------------------------------
-// Settings
-error_reporting(E_ALL | E_STRICT);
-date_default_timezone_set('UTC');
-putenv("PATH=/usr/local/bin:/usr/bin:/bin");
+// Include
+require dirname(__FILE__) . '/hook-common.inc.php';
-function fail($error)
-{
- fwrite(STDERR, $error);
- exit(1);
-}
-
// -----------------------------------------------------------------------------------------------------------------------------
-// Constants
-$version = substr('$Revision$', strlen('$Revision: '), -2);
-$is_DEBUG = (isset($_ENV['DEBUG']) && $_ENV['DEBUG'] === 'DEBUG');
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Version check
-if (version_compare('5.2.0', PHP_VERSION, '>')) {
- fail("Requires at least PHP 5.2.\n");
-}
-if (!defined('__DIR__')) {
- define('__DIR__', dirname(__FILE__));
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
// Arguments
if ($argc !== 3) {
fail("Pass exactly two arguments: REPOS and REV.\n");
@@ -36,51 +14,11 @@
$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) {
- fail("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
- }
- return $output;
-}
+// Read the commit data
+$commit_info = read_commit_information();
// -----------------------------------------------------------------------------------------------------------------------------
-// Build list of changes
-$commit_info = array(
- 'changed_paths' => run_svnlook('changed'),
- 'dirs_changed' => run_svnlook('dirs-changed'),
- 'author' => ($is_DEBUG && getenv("DEBUGUSER")) ? getenv("DEBUGUSER") : trim(implode('', run_svnlook('author'))),
- 'log_message' => trim(implode("\n", run_svnlook('log'))),
- 'date' => strtotime(substr(trim(implode('', run_svnlook('date'))), 0, strlen("0000-00-00 00:00:00 +0000"))),
- 'diffs' => implode("\n", run_svnlook('diff')),
-);
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Read the user database
-$usersDB = file(dirname(__FILE__) . '/users.db');
-$saw_last_ISO = FALSE;
-foreach ($usersDB as $userline) {
- list ($username, $fullname, $email) = explode(":", trim($userline));
- if ($username === 'ladderalice') {
- $saw_last_ISO = TRUE;
- }
- if ($username === $commit_info['author']) {
- if ($saw_last_ISO !== TRUE) {
- $fullname = iconv("ISO-8859-1", "UTF-8//TRANSLIT", $fullname);
- }
- $commit_info['author_name'] = $fullname;
- $commit_info['author_email'] = $email;
- break;
- }
-}
-if (!isset($commit_info['author_name'])) {
- fail("Couldn't find user\n");
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Call various sub-scripts
+// Call the various sub-scripts
require __DIR__ . '/commit-bugs.php';
require __DIR__ . '/commit-email.php';
require __DIR__ . '/commit-svnroot.php';
Modified: SVNROOT/pre-commit
===================================================================
--- SVNROOT/pre-commit 2009-07-24 18:08:42 UTC (rev 284713)
+++ SVNROOT/pre-commit 2009-07-24 18:54:54 UTC (rev 284714)
@@ -2,115 +2,71 @@
<?php
// -----------------------------------------------------------------------------------------------------------------------------
-// Settings
-error_reporting(E_ALL | E_STRICT);
-date_default_timezone_set('UTC');
-putenv("PATH=/usr/local/bin:/usr/bin:/bin");
+// Include
+require dirname(__FILE__) . '/hook-common.inc.php';
-function fail($error)
-{
- fwrite(STDERR, $error);
- exit(1);
-}
-
// -----------------------------------------------------------------------------------------------------------------------------
-// Constants
-$version = substr('$Revision$', strlen('$Revision: '), -2);
-$is_DEBUG = (isset($_ENV['DEBUG']) && $_ENV['DEBUG'] === 'DEBUG');
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Version check
-if (version_compare('5.2.0', PHP_VERSION, '>')) {
- fail("Requires at least PHP 5.2.\n");
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
// Arguments
-if ($argc != 3 && !$is_DEBUG) {
+if ($argc != 3) {
fail("Pass exactly two arguments: REPOS and TXN.\n");
}
$REPOS = $argv[1];
$TXN = $argv[2];
// -----------------------------------------------------------------------------------------------------------------------------
-// Utility
-function run_svnlook($command, $extra_args = array())
-{
- $selector = $GLOBALS['is_DEBUG'] ? '-r' : '-t';
- $cmd = 'exec svnlook ' . escapeshellarg($command) . " {$selector} " . escapeshellarg($GLOBALS['TXN']) . ' ' .
- escapeshellarg($GLOBALS['REPOS']) . ' ' . implode(' ', array_map('escapeshellarg', $extra_args)) . ' 2>&1';
- exec($cmd, $output, $status);
- if ($status != 0) {
- fail("svnlook ({$cmd}) failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\nBacktrace:\n" . print_r(debug_backtrace(), 1));
- }
- return $output;
-}
-
-function pattern_matches_commit($pattern)
-{
- foreach ($GLOBALS['paths_changed'] as $path_changed) {
- if (!preg_match($pattern, $path_changed)) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-function explode_noempty($separator, $str) {
- $result = explode($separator, $str);
- $true_result = array();
- foreach ($result as $element) {
- if (empty($element)) {
- continue;
- }
- $true_result[] = $element;
- }
- return $true_result;
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Build list of changes
+// Read the commit data
if ($is_DEBUG) {
- $paths_changed = explode("\n", trim(stream_get_contents(STDIN)));
- $log_message = array('test1', 'test2');
- $author = $argv[3];
-} else {
- $paths_changed = run_svnlook('changed');
- $log_message = run_svnlook('log');
- $author = trim(implode("\n", run_svnlook('author')));
+ // make svnlook use a revision instead for debugging
+ $REV = $TXN;
+ unset($TXN);
}
-array_walk($paths_changed, create_function('&$v, $k', '$v = trim($v); $v = ltrim(substr($v, strcspn($v, " \t")));'));
+$commit_info = read_commit_information();
// -----------------------------------------------------------------------------------------------------------------------------
// Log message empty?
-if (strlen(trim(implode("\n", $log_message))) == 0) {
+if (strlen($commit_info['log_message']) === 0) {
fail("Please specify a log message.\n");
}
// -----------------------------------------------------------------------------------------------------------------------------
-// Read avail database
-if (pattern_matches_commit('/^pear.*/')) {
- $avail_db = dirname(__FILE__) . '/pear_avail';
-} else {
- $avail_db = dirname(__FILE__) . '/global_avail';
+// Check for denied commits
+foreach ($commit_info['changed_paths'] as $changed_path => $path_actions) {
+ if (strncmp($changed_path, "archived/", strlen("archived/")) === 0) {
+ fail("Commits to archived modules are not allowed.\n");
+ }
+
+ // path contains "/tags/" AND
+ // path was not added OR
+ // path was not copied OR
+ // path is not a directory OR
+ // path's immediate ancestor is not tags/
+ if (strpos($changed_path, '/tags/') !== FALSE &&
+ (!in_array('added', $path_actions) ||
+ !in_array('copied', $path_actions) ||
+ substr($changed_path, -1) !== '/' ||
+ substr(dirname($changed_path), -5) !== '/tags'))
+ {
+ fail("Committing to a tag is not allowed.\n");
+ }
}
-$avail_lines = file($avail_db);
// -----------------------------------------------------------------------------------------------------------------------------
-// Check for denied commits
-if (pattern_matches_commit('/^archived.*/')) {
- fail("Commits to archived modules are not allowed.\n");
-}
+// Read avail database
+$main_avail_db = file(__DIR__ . '/global_avail');
+$pear_avail_db = file(__DIR__ . '/pear_avail');
-// Should match when tags is a component of the path but not the last component
-if (pattern_matches_commit('~/tags/.+~')) {
- fail("Committing to a tag is not allowed.\n");
-}
-
// -----------------------------------------------------------------------------------------------------------------------------
// Check commit against it
$exit_val = 0;
-foreach ($paths_changed as $path_changed) {
+foreach ($commit_info['changed_paths'] as $changed_path => $path_actions) {
+ if (strncmp($changed_path, "pear/", strlen("pear/")) === 0) {
+ $avail_lines = $pear_avail_db;
+ debug("Using PEAR avail.");
+ } else {
+ $avail_lines = $main_avail_db;
+ debug("Using global avail.");
+ }
+
foreach ($avail_lines as $avail_line) {
if (strncmp($avail_line, 'unavail', 7) == 0) {
$bit = 0;
@@ -120,23 +76,16 @@
continue;
}
- $params = explode("|", trim($avail_line));
- if (count($params) == 1) { // avail/unavail by itself
- $userlist = array();
- $modulelist = array();
- } else if (count($params) == 2) { // user list but no mod list
- $userlist = explode_noempty(",", $params[1]);
- $modulelist = array();
- } else {
- $userlist = explode_noempty(",", $params[1]);
- $modulelist = explode_noempty(",", $params[2]);
- }
- $user_in_list = in_array($author, $userlist) || count($userlist) == 0;
+ $params = array_merge(explode("|", trim($avail_line), 3), array("", ""));
+ $modulelist = array_filter(explode(",", $params[2]));
+ $userlist = array_filter(explode(",", $params[1]));
- $in_repo = count($modulelist) == 0;
+ $user_in_list = count($userlist) === 0 || in_array($commit_info['author'], $userlist);
+
+ $in_repo = count($modulelist) === 0;
if (!$in_repo) {
foreach ($modulelist as $module) {
- if (fnmatch("{$module}*", $path_changed)) {
+ if (fnmatch("{$module}*", $changed_path)) {
$in_repo = TRUE;
}
}
@@ -146,80 +95,38 @@
$exit_val = $bit ? 0 : 1;
}
- if ($GLOBALS['is_DEBUG']) {
- if ($user_in_list) {
- print "DEBUG: User {$author} " . ($user_in_list ? "matched" : "did not match") . " user list: " . implode(",", $userlist) . "\n";
- }
- if ($in_repo) {
- print "DEBUG: Path {$path_changed} " . ($in_repo ? "matched" : "did not match") . " repo list: " . implode(",", $modulelist) . "\n";
- }
- if ($user_in_list || $in_repo) {
- print "DEBUG: exit_val == {$exit_val} for " . var_export($user_in_list, 1) . "/" . var_export($in_repo, 1) . ".\n";
- }
+ if ($user_in_list) {
+ debug("User {$commit_info['author']} " . ($user_in_list ? "matched" : "did not match") . " user list: {$params[1]}");
}
+ if ($in_repo) {
+ debug("Path {$changed_path} " . ($in_repo ? "matched" : "did not match") . " repo list: {$params[2]}");
+ }
+ if ($user_in_list || $in_repo) {
+ debug("exit_val == {$exit_val} for " . var_export($user_in_list, 1) . "/" . var_export($in_repo, 1) . ".");
+ }
}
- if ($exit_val) { // if one dir fails, all fail
- $last_path = $path_changed;
+ if ($exit_val) { // if one path fails, all fail
+ $last_path = $changed_path;
break;
}
}
if ($exit_val) {
- if (preg_match('/^pear/', $last_path)) {
+ if (strncmp($last_path, "pear/", strlen("pear/")) === 0) {
$access_contact_email = '[email protected]';
- } else if (preg_match('/^pecl/', $last_path)) {
+ } else if (strncmp($last_path, "pecl/", strlen("pecl/")) === 0) {
$access_contact_email = '[email protected]';
- } else if (preg_match('/^phpdoc/', $last_path)) {
+ } else if (strncmp($last_path, "phpdoc/", strlen("phpdoc/")) === 0) {
$access_contact_email = '[email protected]';
} else {
$access_contact_email = '[email protected]';
}
- fail("*******\nAccess denied: Insufficient karma for {$author} to {$last_path}.\nContact {$access_contact_email} for access.\n");
+ fail("*******\nAccess denied: Insufficient karma for {$commit_info['author']} to {$last_path}.\nContact {$access_contact_email} for access.\n");
}
-if ($is_DEBUG) {
- print "DEBUG: Access granted.\n";
-}
+debug("Access granted.");
-// -----------------------------------------------------------------------------------------------------------------------------
-// CHECK DISABLED BY POPULAR SCREAMING
-// Changing text files requires svn:keywords set
-/*
-$paths_added = array_filter($paths_changed, create_function('$v', 'return ($v[0] === "A");'));
-foreach ($paths_added as $path_added) {
- preg_match('/^([^[:space:]]+)[[:space:]]+(.*)$/uX', $path_added, $matches);
- $path_added = $matches[2];
- if ($is_DEBUG) {
- print "DEBUG: Checking properties for {$path_added}.\n";
- }
- if (substr($path_added, -1) === '/') { // is a directory?
- continue;
- }
-
- $properties = array_map('trim', run_svnlook('proplist', array($path_added)));
- if (in_array('svn:mime-type', $properties)) {
- $mimetype = trim(implode("\n", run_svnlook('propget', array('svn:mime-type', $path_added))));
- } else {
- $mimetype = 'text/unknown';
- }
-
- if (strncmp($mimetype, "text/", 5) === 0) {
- if ($is_DEBUG) {
- print "DEBUG: File is non-binary. Checking for keywords.\n";
- }
- if (!in_array('svn:keywords', $properties)) {
- fail("svn:keywords not set on textual file {$path_added}. Please see section 5 of http://darkrainfall.org/phpsvn-guide.html for instructions.\n");
- }
- if ($is_DEBUG) {
- print "DEBUG: File has keywords. Moving on.\n";
- }
- } else if ($is_DEBUG) {
- print "DEBUG: File is binary. Moving on.\n";
- }
-}
-*/
-
exit(0);
?>
Modified: SVNROOT/start-commit
===================================================================
--- SVNROOT/start-commit 2009-07-24 18:08:42 UTC (rev 284713)
+++ SVNROOT/start-commit 2009-07-24 18:54:54 UTC (rev 284714)
@@ -2,28 +2,10 @@
<?php
// -----------------------------------------------------------------------------------------------------------------------------
-// Settings
-error_reporting(E_ALL | E_STRICT);
-date_default_timezone_set('UTC');
-putenv("PATH=/usr/local/bin:/usr/bin:/bin");
+// Include
+require dirname(__FILE__) . '/hook-common.inc.php';
-function fail($error)
-{
- fwrite(STDERR, $error);
- exit(1);
-}
-
// -----------------------------------------------------------------------------------------------------------------------------
-// Constants
-$version = substr('$Revision$', strlen('$Revision: '), -2);
-
-// -----------------------------------------------------------------------------------------------------------------------------
-// Version check
-if (version_compare('5.2.0', PHP_VERSION, '>')) {
- fail("Requires at least PHP 5.2.\n");
-}
-
-// -----------------------------------------------------------------------------------------------------------------------------
// Arguments
if ($argc != 4) {
fail("Pass exactly three arguments: REPOS, USER, and CAPABILITIES.\n");
@@ -33,21 +15,10 @@
$CAPABILITIES = explode(':', $argv[3]);
// -----------------------------------------------------------------------------------------------------------------------------
-// Does the user exist?
-$userfile = file(dirname(__FILE__) . '/users.db');
-$userexists = FALSE;
-foreach ($userfile as $userinfo) {
- list($username, $realm, $md5) = explode(':', $userinfo, 3);
- if ($username === $USER) {
- $userexists = TRUE;
- break;
- }
-}
+// We don't actually need to do anything. Checking whether the given user exists
+// will be done by both Apache/svnserve *and* pre-commit. This hook is therefore
+// just a placeholder for now.
-if (!$userexists) {
- fail("No such user.\n");
-}
-
// -----------------------------------------------------------------------------------------------------------------------------
// Proceed to pre-commit authorization
exit(0);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php