2 <?php # vim:ts=2:sw=2:et:ft=php:
3 /* For licensing and copyright terms, see the file named LICENSE */
5 // svn-commit-hook [pre|post] svnrepopath svntxn [fakerepo]
6 // php /path/to/mtrack/bin/svn-commit-hook pre $1 $2 /var/cache/git/......
8 // this is an example file, you should add remove lines to suit your need..
10 die("MAKE INTO CLASS");
14 $svntxn = ($action == 'pre') ? "-t {$argv[3]}" : "-r {$argv[3]}";
16 include dirname(__FILE__) . '/../inc/common.php';
17 require_once 'SCM/Svn/CommitHookBridge.php';
19 MTrackConfig::checkInitializing();
21 // load up any checks...
22 MTrackCommitChecker::addCheck('NoEmptyLogMessage');
23 MTrackCommitChecker::addCheck('BlankLines');
24 MTrackCommitChecker::addCheck('UnixLineBreak');
25 MTrackCommitChecker::addCheck('SingleIssue');
26 MTrackCommitChecker::addCheck('PhpLint');
30 //$repo = MTrackRepo::loadByLocation($svnrepo);
31 $repo = MTrackRepo::loadByLocation( $svnrepo);
32 $bridge = new MTrack_SCM_Svn_CommitHookBridge($repo, $svnrepo, $svntxn);
34 $author = trim(fread($bridge->run($bridge->svnlook, 'author', $bridge->svntxn, $bridge->svnrepo),1024));
35 $author = mtrack_canon_username($author);
36 MTrackAuth::su($author);
38 $checker = new MTrackCommitChecker($repo);
39 if ($action == 'pre') {
40 $checker->preCommit($bridge);
42 $checker->postCommit($bridge);
46 } catch (Exception $e) {
48 fwrite(STDERR, "\n" . $e->getMessage() . "\n\n ** Commit failed [$action]\n");