5 class MTrack_SCM_Git_WorkingCopy extends MTrackSCMWorkingCopy
10 function __construct(MTrack_Repo $repo) {
11 $cfg = HTML_FlexyFramework::get()->MTrack;
12 if (empty($cfg['workingdir'])) {
13 throw new Exception("MTrack[workingdir] is not set")
15 $this->dir = $cfg['workingdir'];
18 MTrackSCM::run('git', 'string',
19 array('clone', $this->repo->repopath, $this->dir)
23 function __destruct() {
25 echo stream_get_contents($this->git('push'));
27 mtrack_rmdir($this->dir);
30 function getFile($path)
32 return $this->repo->file($path);
35 function addFile($path)
37 $this->git('add', $path);
40 function delFile($path)
42 $this->git('rm', '-f', $path);
45 function commit(MTrackChangeset $CS)
48 $d = strtotime($CS->when);
49 putenv("GIT_AUTHOR_DATE=$d -0000");
51 putenv("GIT_AUTHOR_DATE=");
53 $reason = trim($CS->reason);
54 if (!strlen($reason)) {
57 putenv("GIT_AUTHOR_NAME=$CS->who");
58 putenv("GIT_AUTHOR_EMAIL=$CS->who");
59 stream_get_contents($this->git('commit', '-a',
67 $args = func_get_args();
68 $a = array("--git-dir=$this->dir/.git", "--work-tree=$this->dir");
69 foreach ($args as $arg) {
73 return MTrackSCM::run('git', 'read', $a);