<?php
-class MTrack_SCM_Git_WorkingCopy extends MTrackSCMWorkingCopy {
- private $repo;
- public $push = true;
+/***
+ *
+ * working directories?
+ *
+ * This is very dodgy..
+ * = either we have a temporary working directory created for each session/user etc..
+ *
+ * = what happens when multiple people try to access a working directory..
+ *
+ * = what happens if the same person is doing multiple things on the same workign directory..
+ *
+ *
+ *
+ *
+ */
+require_once 'MTrack/SCM/WorkingCopy.php';
- function __construct(MTrack_Repo $repo) {
- $this->dir = mtrack_make_temp_dir();
- $this->repo = $repo;
+
+class MTrack_SCM_Git_WorkingCopy extends MTrack_SCM_WorkingCopy
+{
+ private $repo;
+ public $push = false; ///
+
+ function __construct(MTrack_Repo $repo) {
+
+ $this->dir = $this->generateTempDir();;
+
+ $this->repo = $repo;
+
+ MTrackSCM::run('git', 'string',
+ array('clone', $this->repo->repopath, $this->dir)
+ );
+ }
- MTrackSCM::run('git', 'string',
- array('clone', $this->repo->repopath, $this->dir)
- );
- }
-
- function __destruct() {
- if ($this->push) {
- echo stream_get_contents($this->git('push'));
+ function push()
+ {
+ return stream_get_contents($this->git('push'));
}
- mtrack_rmdir($this->dir);
- }
-
- function getFile($path)
- {
- return $this->repo->file($path);
- }
-
- function addFile($path)
- {
- $this->git('add', $path);
- }
-
- function delFile($path)
- {
- $this->git('rm', '-f', $path);
- }
-
- function commit(MTrackChangeset $CS)
- {
- if ($CS->when) {
- $d = strtotime($CS->when);
- putenv("GIT_AUTHOR_DATE=$d -0000");
- } else {
- putenv("GIT_AUTHOR_DATE=");
+
+
+
+ function getFile($path)
+ {
+ return $this->repo->file($path);
}
- $reason = trim($CS->reason);
- if (!strlen($reason)) {
- $reason = 'Changed';
+
+ function addFile($path)
+ {
+ $this->git('add', $path);
}
- putenv("GIT_AUTHOR_NAME=$CS->who");
- putenv("GIT_AUTHOR_EMAIL=$CS->who");
- stream_get_contents($this->git('commit', '-a',
- '-m', $reason
- )
- );
- }
-
- function git()
- {
- $args = func_get_args();
- $a = array("--git-dir=$this->dir/.git", "--work-tree=$this->dir");
- foreach ($args as $arg) {
- $a[] = $arg;
+
+ function delFile($path)
+ {
+ $this->git('rm', '-f', $path);
+ }
+ /**
+ * @param {StdClass} $CS
+ * ->when (optional)
+ * ->reason (optional)???
+ * ->name (required)
+ * ->email (required)
+ */
+
+ function commit( $CS)
+ {
+
+ if ($CS->when) {
+ $d = strtotime($CS->when);
+ putenv("GIT_AUTHOR_DATE=$d -0000");
+ } else {
+ putenv("GIT_AUTHOR_DATE=");
+ }
+
+ $reason = trim($CS->reason);
+ if (!strlen($reason)) {
+ $reason = 'Changed';
+ }
+ print_R($CS);exit;
+ echo implode(" ", array('commit', '-a', '-m', $reason ,
+ '--author="' . $CS->name . ' <'. $CS->email . '>"' ));exit;
+ exit;
+ return stream_get_contents(
+ $this->git('commit', '-a', '-m', $reason ,
+ '--author="' . $CS->name . ' <'. $CS->email . '>"' )
+ );
+ }
+
+ function git()
+ {
+ $args = func_get_args();
+ $a = array("--git-dir=$this->dir/.git", "--work-tree=$this->dir");
+ foreach ($args as $arg) {
+ $a[] = $arg;
+ }
+ print_r($a);
+ return MTrackSCM::run('git', 'read', $a);
}
- print_r($a);
- return MTrackSCM::run('git', 'read', $a);
- }
}