final move of files
[web.mtrack] / MTrackWeb / Hook / svn.php
1 #!/usr/bin/env php
2 <?php # vim:ts=2:sw=2:et:ft=php:
3 /* For licensing and copyright terms, see the file named LICENSE */
4 // called as:
5 // svn-commit-hook [pre|post] svnrepopath svntxn [fakerepo]
6 // php /path/to/mtrack/bin/svn-commit-hook pre $1 $2 /var/cache/git/......
7
8 // this is an example file, you should add remove lines to suit your need..
9
10 die("MAKE INTO CLASS");
11
12 $action = $argv[1];
13 $svnrepo = $argv[2];
14 $svntxn = ($action == 'pre') ? "-t {$argv[3]}" : "-r {$argv[3]}"; 
15
16 include dirname(__FILE__) . '/../inc/common.php';
17 require_once 'SCM/Svn/CommitHookBridge.php';
18
19 MTrackConfig::checkInitializing();
20
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');
27
28
29 try {
30   //$repo = MTrackRepo::loadByLocation($svnrepo);
31     $repo = MTrackRepo::loadByLocation(   $svnrepo);
32     $bridge = new MTrack_SCM_Svn_CommitHookBridge($repo, $svnrepo, $svntxn);
33
34     $author = trim(fread($bridge->run($bridge->svnlook, 'author', $bridge->svntxn, $bridge->svnrepo),1024));
35     $author = mtrack_canon_username($author);
36     MTrackAuth::su($author);
37
38     $checker = new MTrackCommitChecker($repo);
39     if ($action == 'pre') {
40         $checker->preCommit($bridge);
41     } else {
42         $checker->postCommit($bridge);
43     }
44     exit(0);
45
46 } catch (Exception $e) {
47     
48     fwrite(STDERR, "\n" . $e->getMessage() . "\n\n ** Commit failed [$action]\n");
49     exit(1);
50 }
51