Fix #5661 - MTrack - daily email large and no branch
[web.mtrack] / MTrack / CommitChecker.php
index 1aba39e..e1c2091 100644 (file)
@@ -192,11 +192,14 @@ class MTrack_CommitChecker {
         } else {
             require_once 'MTrack/CommitHookChangeEvent.php';
             $c = new MTrackCommitHookChangeEvent;
-            $c->rev = $bridge->getChangesetDescriptor();
-            $c->changelog = $bridge->getCommitMessage();
-            $c->changeby = $this->authUser->email; //???
+            $c->rev         = $bridge->getChangesetDescriptor();
+            $c->changelog   = $bridge->getCommitMessage();
+            $c->changeby    = $this->authUser->email; //???
             $c->changeby_id = $this->authUser->id; //???
-            $c->ctime = time();
+            $c->branch       = $bridge->branch;
+            //print_r($bridge);exit;
+            $c->ctime       = isset($bridge->props['Date']) ? strtotime($bridge->props['Date']) : time();
+            $c->fileActions = $bridge->fileActions;
             $changes[] = $c;
         }
         return $changes;
@@ -208,6 +211,10 @@ class MTrack_CommitChecker {
         // this might be run on multiple commits (big push...)
         
         
+        // in our system, we not only log commits that are against a
+        // ticket, but also ones that are not..
+        
+        
         $files = $bridge->enumChangedOrModifiedFileNames();
         
         $fqfiles = array();
@@ -217,6 +224,10 @@ class MTrack_CommitChecker {
 
         // build up overall picture of what needs to be applied to tickets
         $changes = $this->_getChanges($bridge);
+        
+        
+        //print_R($changes);
+        
 
         // Deferred by tid
         $deferred = array();
@@ -232,6 +243,9 @@ class MTrack_CommitChecker {
         
         $me = $this->authUser;
 
+
+
+
         foreach ($changes as $c) {
             $tickets = array();
             $log = $c->changelog;
@@ -247,19 +261,28 @@ class MTrack_CommitChecker {
             }
             if (count($tickets) == 0) {
                 $no_ticket[] = $c;
+                
                 continue;
             }
             
             // apply changes to tickets
+            $T = false;
             foreach ($tickets as $tkt => $act) {
                 // removed all the code that handles hashed ticked ids...
-                $T = clone($this->ticketProvider);
+                //DB_DataObject::DebugLevel(1);
+                $T = DB_DataObject::Factory('mtrack_ticket');
+                $T->project_id = $this->repo->project_id;
                 if (!$T->get($tkt)) {
                     continue;
                 }
+                break;
                 
                 $T_by_tid[$T->id] = $T;
             }
+            
+            if (!$T) {
+                continue;
+            }
             /*
             $accounted = false;
             
@@ -299,23 +322,39 @@ class MTrack_CommitChecker {
                   $log .= " (on behalf of [user:$c->changeby]) ";
                 }
                 */
+                
+            // for the stuff below we do not currently support multiple tickets..
             
             $log .= $c->changelog;
+            if (!isset($deferred[$T->id])) {
+                $deferred[$T->id] = array(
+                    'comments' => array(),
+                    'changes' => array(),
+                    'act' => array(),
+                    'ticket' => $T
+                    
+                );
+            }
+            
             
             $deferred[$T->id]['comments'][] = $log;
+            $deferred[$T->id]['changes'][] = $c;
+            
+            
             
             if (isset($act['spent']) && $c->changeby != $me) {
                 $spent_by_tid_by_user[$T->id][$c->changeby_id][] = $act['spent'];
                 unset($act['spent']);
             }
-            $deferred[$T->tid]['act'][] = $act;
+            $deferred[$T->id]['act'][] = $act;
  
             //??? 
             $this->checkVeto('postCommit', $log, $fqfiles, $actions);
         }
         
-        // defered is a list of actions...
         
+        // defered is a list of actions...
+        $this->no_ticket = $no_ticket;
         $this->deferred = $deferred;
         $this->spent_by_tid_by_user = $spent_by_tid_by_user;