7 * #repo/hooks/post-receive
8 * /usr/bin/php {PATH TO APPLICATION}/index.php Hook/git post >> /tmp/githooklog
16 /* For licensing and copyright terms, see the file named LICENSE */
19 // git-commit-hook what [mtrackconfig] > /tmp/gitlog
20 // the cwd is the repo path
21 // a list of "oldrev newrev refname" lines is presented to us on stdin
24 require_once 'MTrackWeb.php';
26 class MTrackWeb_Hook_git extends MTrackWeb
30 if (!HTML_FlexyFramework::get()->cli) {
40 $repo = DB_DataObject::factory('mtrack_repos');
41 $repo->repopath = getcwd();
42 if (!$repo->find(true)) {
43 $this->addEvent("HOOKERROR", false, "invalid repo:". getcwd() );
44 die("INVALID REPO" . getcwd() );
48 require_once 'MTrack/SCM/Git/CommitHookBridge.php';
50 $bridge = new MTrack_SCM_Git_CommitHookBridge($repo);
52 die("work out user?");
54 // WTF is this for.. it the hook should be telling who the user is.
55 $author = 'www-data';//MTrackAuth::whoami();
56 $author = mtrack_canon_username($author);
57 MTrackAuth::su($author);
59 $checker = new MTrackCommitChecker($repo);
64 $checker->preCommit($bridge);
68 $checker->postCommit($bridge);
76 } catch (Exception $e) {
78 fwrite(STDERR, "\n" . $e->getMessage() .
80 $e->getTraceAsString() .
81 "\n\n ** Commit failed [$action]\n");