3 class MTrack_SCM_Git_WorkingCopy extends MTrackSCMWorkingCopy {
7 function __construct(MTrackRepo $repo) {
8 $this->dir = mtrack_make_temp_dir();
11 MTrackSCM::run('git', 'string',
12 array('clone', $this->repo->repopath, $this->dir)
16 function __destruct() {
18 echo stream_get_contents($this->git('push'));
20 mtrack_rmdir($this->dir);
23 function getFile($path)
25 return $this->repo->file($path);
28 function addFile($path)
30 $this->git('add', $path);
33 function delFile($path)
35 $this->git('rm', '-f', $path);
38 function commit(MTrackChangeset $CS)
41 $d = strtotime($CS->when);
42 putenv("GIT_AUTHOR_DATE=$d -0000");
44 putenv("GIT_AUTHOR_DATE=");
46 $reason = trim($CS->reason);
47 if (!strlen($reason)) {
50 putenv("GIT_AUTHOR_NAME=$CS->who");
51 putenv("GIT_AUTHOR_EMAIL=$CS->who");
52 stream_get_contents($this->git('commit', '-a',
60 $args = func_get_args();
61 $a = array("--git-dir=$this->dir/.git", "--work-tree=$this->dir");
62 foreach ($args as $arg) {
66 return MTrackSCM::run('git', 'read', $a);