MTrack/SCM/Git/WorkingCopy.php
authorAlan Knowles <alan@akbkhome.com>
Tue, 6 Sep 2011 08:26:24 +0000 (16:26 +0800)
committerAlan Knowles <alan@akbkhome.com>
Tue, 6 Sep 2011 08:26:24 +0000 (16:26 +0800)
MTrack/SCM/Git/WorkingCopy.php

index e19c4df..20248ab 100644 (file)
@@ -1,68 +1,71 @@
 <?php
 
-class MTrack_SCM_Git_WorkingCopy extends MTrackSCMWorkingCopy {
-  private $repo;
-  public $push = true;
 
-  function __construct(MTrack_Repo $repo) {
-    $this->dir = mtrack_make_temp_dir();
-    $this->repo = $repo;
-    
-    MTrackSCM::run('git', 'string',
-        array('clone', $this->repo->repopath, $this->dir)
-    );
-  }
 
-  function __destruct() {
-    if ($this->push) {
-      echo stream_get_contents($this->git('push'));
+class MTrack_SCM_Git_WorkingCopy extends MTrackSCMWorkingCopy
+{
+    private $repo;
+    public $push = true;
+  
+    function __construct(MTrack_Repo $repo) {
+        $this->dir = mtrack_make_temp_dir();
+        $this->repo = $repo;
+        
+        MTrackSCM::run('git', 'string',
+            array('clone', $this->repo->repopath, $this->dir)
+        );
     }
-    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 __destruct() {
+        if ($this->push) {
+          echo stream_get_contents($this->git('push'));
+        }
+        mtrack_rmdir($this->dir);
     }
-    $reason = trim($CS->reason);
-    if (!strlen($reason)) {
-      $reason = 'Changed';
+  
+    function getFile($path)
+    {
+         return $this->repo->file($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 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=");
+        }
+        $reason = trim($CS->reason);
+        if (!strlen($reason)) {
+          $reason = 'Changed';
+        }
+        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;
+        }
+        print_r($a);
+        return MTrackSCM::run('git', 'read', $a);
     }
-    print_r($a);
-    return MTrackSCM::run('git', 'read', $a);
-  }
 }