var $authUser;
var $checks = array();
+
function __construct($ar) {
foreach($ar as $k=>$v) {
$this->$k = $v;
}
+
function checkVeto()
{
} else {
require_once 'MTrack/CommitHookChangeEvent.php';
$c = new MTrackCommitHookChangeEvent;
- $c->rev = $bridge->getChangesetDescriptor();
- $c->changelog = $bridge->getCommitMessage();
- $c->changeby = $this->authUser->email; //???
- $c->changeby)id = $this->authUser->id; //???
- $c->ctime = time();
+ $c->rev = $bridge->getChangesetDescriptor();
+ $c->changelog = $bridge->getCommitMessage();
+ $c->changeby = $this->authUser->email; //???
+ $c->changeby_id = $this->authUser->id; //???
+ //print_r($bridge);exit;
+ $c->ctime = isset($bridge->props['Date']) ? strtotime($bridge->props['Date']) : time();
+ $c->fileActions = $bridge->fileActions;
$changes[] = $c;
}
return $changes;
function postCommit(IMTrackCommitHookBridge $bridge)
{
+
+ // 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();
// build up overall picture of what needs to be applied to tickets
$changes = $this->_getChanges($bridge);
+
+
+ //print_R($changes);
+
// Deferred by tid
$deferred = array();
$me = $this->authUser;
+
+
+
foreach ($changes as $c) {
$tickets = array();
$log = $c->changelog;
}
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;
$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][] = $act['spent'];
+ $spent_by_tid_by_user[$T->id][$c->changeby_id][] = $act['spent'];
unset($act['spent']);
}
- $deferred[$T->tid]['act'][] = $act;
-
- }
- $this->checkVeto('postCommit', $log, $fqfiles, $actions);
+ $deferred[$T->id]['act'][] = $act;
+
+ //???
+ $this->checkVeto('postCommit', $log, $fqfiles, $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;
+
+
+ return true;
+
+ /*
+ $ret = array();
// print_r($deferred);
foreach ($deferred as $tid => $info) {
- $T = $T_by_tid[$tid];
-
- $log = join("\n\n", $info['comments']);
+ $T = $T_by_tid[$tid];
+ $log = join("\n\n", $info['comments']);
+
+
+
+
+
$CS = MTrackChangeset::begin("ticket:" . $T->tid, $log);
if (isset($hashed[$T->tid])) {
}
$CS = MTrackChangeset::begin("repo:" . $this->repo->id, $log);
$CS->commit();
+
+ */
}