MTrack/SCM/Git/CommitHookBridge.php
[web.mtrack] / MTrack / SCM / Git / CommitHookBridge.php
index 136569d..ecdb9c2 100644 (file)
@@ -1,7 +1,7 @@
-<?php  
-require_once 'Mtrack/Interface/CommitHookBridge.php';
-require_once 'Mtrack/Repo.php';
+<?php
 
+require_once 'MTrack/Interface/CommitHookBridge.php';
+require_once 'MTrack/Repo.php';
 
 // needs to be run from git-recieve (and it has to be the only thing run.
 
@@ -14,22 +14,23 @@ class MTrack_SCM_Git_CommitHookBridge extends  IMTrackCommitHookBridge
     var $log = array();
     var $commits = array();
     var $fileActions = array(); // file=> delete / modify etc..
-    
+    var $props = array(); // date etc..
     
     /**
     * fills up repo, files, log, commits by running log on the STDIN
     */
     
-    function __construct(MTrack_Repo $repo, $hooks
+    function __construct($repo
     {
-        $this->repo = $repo;
+        $this->repo = $repo->impl();
         while (($line = fgets(STDIN)) !== false) {
             echo "got: $line\n";
             list($old, $new, $ref) = explode(' ', trim($line), 3);
             $this->commits[] = $new;
   
-            $fp = $this->repo->git('log', '--no-color', '--name-status',
-                '--date=rfc', $ref, "$old..$new");
+            $fp = $this->repo->git(
+                'log', '--no-color', '--name-status',
+                '--date=rfc',  "$old..$new"); //$ref, used to be in here??  - but it breaks stuff...
                 
                 
             $props = array();
@@ -37,13 +38,13 @@ class MTrack_SCM_Git_CommitHookBridge extends  IMTrackCommitHookBridge
             if (!preg_match("/^commit\s+(\S+)$/", $line)) {
                 throw new Exception("unexpected output from git log: $line");
             }
-            
+            $this->props = array();
             // read key: value properties like Author: / Date: 
             while (($line = fgets($fp)) !== false) {
                 $line = rtrim($line);
                 if (!strlen($line)) break;
                 if (preg_match("/^(\S+):\s*(.*)\s*$/", $line, $M)) {
-                    $props[$M[1]] = $M[2];
+                    $this->props[$M[1]] = $M[2];
                 }
             }
             // read the commit log.
@@ -66,6 +67,7 @@ class MTrack_SCM_Git_CommitHookBridge extends  IMTrackCommitHookBridge
               
             } while (($line = fgets($fp)) !== false);
         }
+        //print_r($this);exit;
     }