5 class MTrack_SCM_Git_WorkingCopy extends MTrackSCMWorkingCopy
10 function __construct(MTrack_Repo $repo) {
11 $this->dir = mtrack_make_temp_dir();
14 MTrackSCM::run('git', 'string',
15 array('clone', $this->repo->repopath, $this->dir)
19 function __destruct() {
21 echo stream_get_contents($this->git('push'));
23 mtrack_rmdir($this->dir);
26 function getFile($path)
28 return $this->repo->file($path);
31 function addFile($path)
33 $this->git('add', $path);
36 function delFile($path)
38 $this->git('rm', '-f', $path);
41 function commit(MTrackChangeset $CS)
44 $d = strtotime($CS->when);
45 putenv("GIT_AUTHOR_DATE=$d -0000");
47 putenv("GIT_AUTHOR_DATE=");
49 $reason = trim($CS->reason);
50 if (!strlen($reason)) {
53 putenv("GIT_AUTHOR_NAME=$CS->who");
54 putenv("GIT_AUTHOR_EMAIL=$CS->who");
55 stream_get_contents($this->git('commit', '-a',
63 $args = func_get_args();
64 $a = array("--git-dir=$this->dir/.git", "--work-tree=$this->dir");
65 foreach ($args as $arg) {
69 return MTrackSCM::run('git', 'read', $a);