3 require_once 'MTrack/SCMEvent.php';
4 class MTrack_SCM_Git_Event extends MTrackSCMEvent
8 /** Revision or changeset identifier for this particular file */
11 /** commit message associated with this revision */
14 /** who committed this revision */
17 /** branch for this revision */
19 /** when this revision was committed */
22 /** files affected in this event; may be null, but otherwise
23 * will be an array of MTrackSCMFileEvent */
30 * this is based on the output from git --raw --numstat
32 static function newFromCommit($commit, $repo)
35 $ent = new MTrack_SCM_Git_Event;
36 $ent->commit = $commit;
38 $lines = explode("\n", $commit);
39 $line = array_shift($lines);
41 if (!preg_match("/^commit\s+(\S+)\s+(\S+)$/", $line, $M)) {
45 $ent->branch = $M[2] ;
46 $ent->tags = array(); // FIXME
47 $ent->files = array();
49 while (count($lines)) {
50 $line = array_shift($lines);
54 if (preg_match("/^(\S+):\s+(.*)\s*$/", $line, $M)) {
64 $ent->ctime = MTrackDB::unixtime($ts);
72 if ($lines[0] == '') {
76 while (count($lines)) {
77 $line = array_shift($lines);
78 if (strncmp($line, ' ', 4)) {
79 array_unshift($lines, $line);
82 $line = substr($line, 4);
83 $ent->changelog .= $line . "\n";
86 if ($lines[0] == '') {
89 // this should only be the last set of lines..
91 foreach ($lines as $line) {
96 if (preg_match('#^:#', $line)) {
97 // it's our stat line..:
98 // :100755 100755 fde93abd1a71accd3aa7e97b29c1eecfb43095d7
99 // 3d71edf6512035846d8164c3b28818de0062335a M web/MTrackWeb/DataObjects/Changes.php
100 $info = preg_split('#\s+#', substr($line ,1), 6);
102 $f = new MTrackSCMFileEvent; //generic..
104 $f->oldperm = $info[0];
105 $f->newperm = $info[1];
106 $f->oldver = $info[2];
107 $f->newver = $info[3];
108 $f->status = $info[4];
109 $ent->files[$f->name] = $f;
113 $info = preg_split('#\s+#', substr($line ,1), 3);
116 if (!isset($ent->files[$name])) {
117 $ent->files[$name] = new stdClass; // ??
120 $ent->files[$name]->added = $info[0];
121 $ent->files[$name]->removed = $info[1];
124 //if (!count($ent->branches)) {
125 // $ent->branches[] = $this->branch; //'master';
127 $ent->files_array = array_values($ent->files);