commit = $commit; $ent->repo = $repo; $lines = explode("\n", $commit); $line = array_shift($lines); if (!preg_match("/^commit\s+(\S+)\s+(\S+)$/", $line, $M)) { return false; } $ent->rev = $M[1]; $ent->branch = $M[2] ; $ent->tags = array(); // FIXME $ent->files = array(); while (count($lines)) { $line = array_shift($lines); if (!strlen($line)) { break; } if (preg_match("/^(\S+):\s+(.*)\s*$/", $line, $M)) { $k = $M[1]; $v = $M[2]; switch ($k) { case 'Author': $ent->changeby = $v; break; case 'Date': $ts = strtotime($v); $ent->ctime = MTrackDB::unixtime($ts); break; } } } $ent->changelog = ""; if ($lines[0] == '') { array_shift($lines); } while (count($lines)) { $line = array_shift($lines); if (strncmp($line, ' ', 4)) { array_unshift($lines, $line); break; } $line = substr($line, 4); $ent->changelog .= $line . "\n"; } if ($lines[0] == '') { array_shift($lines); } // this should only be the last set of lines.. foreach ($lines as $line) { if (!strlen($line)) { continue; } if (preg_match('#^:#', $line)) { // it's our stat line..: // :100755 100755 fde93abd1a71accd3aa7e97b29c1eecfb43095d7 // 3d71edf6512035846d8164c3b28818de0062335a M web/MTrackWeb/DataObjects/Changes.php $info = preg_split('#\s+#', substr($line ,1), 6); // print_r($info); $f = new MTrackSCMFileEvent; //generic.. $f->name = $info[5]; $f->oldperm = $info[0]; $f->newperm = $info[1]; $f->oldver = $info[2]; $f->newver = $info[3]; $f->status = $info[4]; $ent->files[$f->name] = $f; continue; } $info = preg_split('#\s+#', substr($line ,1), 3); //print_r($info); $name = $info[2]; if (!isset($ent->files[$name])) { $ent->files[$name] = new stdClass; // ?? } $ent->files[$name]->added = $info[0]; $ent->files[$name]->removed = $info[1]; } // fixme.. //if (!count($ent->branches)) { // $ent->branches[] = $this->branch; //'master'; //} $ent->files_array = array_values($ent->files); return $ent; } }