* code for task#1365.

This commit is contained in:
xia0ta0
2013-08-26 10:39:09 +08:00
parent 967f9cd0e5
commit 2ddd389a21
6 changed files with 60 additions and 27 deletions
+3
View File
@@ -89,6 +89,7 @@ $lang->action->desc->editestimate = '$date, <strong>$actor</strong> edited wor
$lang->action->desc->deleteestimate = '$date, <strong>$actor</strong> deleted working hours';
$lang->action->desc->canceled = '$date, canceled by <strong>$actor</strong>.';
$lang->action->desc->svncommited = '$date, <strong>$actor</strong> commited to svn,revision is <strong>#$extra</strong>.' . "\n";
$lang->action->desc->gitcommited = '$date, <strong>$actor</strong> commited to git,revision is <strong>#$extra</strong>.' . "\n";
$lang->action->desc->finished = '$date, finished by <strong>$actor</strong>.';
$lang->action->desc->diff1 = 'changed <strong><i>%s</i></strong>, old is "%s", new is "%s".<br />';
$lang->action->desc->diff2 = 'changed <strong><i>%s</i></strong>, the diff is:' . "\n" . "<blockquote>%s</blockquote>" . "\n<div class='hidden'>%s</div>";
@@ -119,6 +120,7 @@ $lang->action->label->tostory = 'converted to story';
$lang->action->label->frombug = 'converted from bug';
$lang->action->label->totask = 'converted to task';
$lang->action->label->svncommited = 'commited code';
$lang->action->label->gitcommited = 'commited code';
$lang->action->label->linked2plan = 'link to plan';
$lang->action->label->unlinkedfromplan = 'unlink from plan';
$lang->action->label->marked = 'edited';
@@ -191,6 +193,7 @@ $lang->action->search->label['tostory'] = $lang->action->label->tost
$lang->action->search->label['frombug'] = $lang->action->label->frombug;
$lang->action->search->label['totask'] = $lang->action->label->totask;
$lang->action->search->label['svncommited'] = $lang->action->label->svncommited;
$lang->action->search->label['gitcommited'] = $lang->action->label->gitcommited;
$lang->action->search->label['linked2plan'] = $lang->action->label->linked2plan;
$lang->action->search->label['unlinkedfromplan'] = $lang->action->label->unlinkedfromplan;
$lang->action->search->label['linked2project'] = $lang->action->label->linked2project;
+3
View File
@@ -89,6 +89,7 @@ $lang->action->desc->editestimate = '$date, 由 <strong>$actor</strong> 编辑
$lang->action->desc->deleteestimate = '$date, 由 <strong>$actor</strong> 删除工时。';
$lang->action->desc->canceled = '$date, 由 <strong>$actor</strong> 取消。' . "\n";
$lang->action->desc->svncommited = '$date, 由 <strong>$actor</strong> 提交代码,版本为<strong>#$extra</strong>。' . "\n";
$lang->action->desc->gitcommited = '$date, 由 <strong>$actor</strong> 提交代码,版本为<strong>#$extra</strong>。' . "\n";
$lang->action->desc->finished = '$date, 由 <strong>$actor</strong> 完成。' . "\n";
$lang->action->desc->diff1 = '修改了 <strong><i>%s</i></strong>,旧值为 "%s",新值为 "%s"。<br />' . "\n";
$lang->action->desc->diff2 = '修改了 <strong><i>%s</i></strong>,区别为:' . "\n" . "<blockquote>%s</blockquote>" . "\n<div class='hidden'>%s</div>";
@@ -119,6 +120,7 @@ $lang->action->label->tostory = '转需求';
$lang->action->label->frombug = '转需求';
$lang->action->label->totask = '转任务';
$lang->action->label->svncommited = '提交代码';
$lang->action->label->gitcommited = '提交代码';
$lang->action->label->linked2plan = '关联计划';
$lang->action->label->unlinkedfromplan = '移除计划';
$lang->action->label->marked = '编辑了';
@@ -191,6 +193,7 @@ $lang->action->search->label['tostory'] = $lang->action->label->tost
$lang->action->search->label['frombug'] = $lang->action->label->frombug;
$lang->action->search->label['totask'] = $lang->action->label->totask;
$lang->action->search->label['svncommited'] = $lang->action->label->svncommited;
$lang->action->search->label['gitcommited'] = $lang->action->label->gitcommited;
$lang->action->search->label['linked2plan'] = $lang->action->label->linked2plan;
$lang->action->search->label['unlinkedfromplan'] = $lang->action->label->unlinkedfromplan;
$lang->action->search->label['linked2project'] = $lang->action->label->linked2project;
+2 -1
View File
@@ -193,6 +193,7 @@ class actionModel extends model
foreach($actions as $actionID => $action)
{
if(strtolower($action->action) == 'svncommited' and isset($commiters[$action->actor])) $action->actor = $commiters[$action->actor];
if(strtolower($action->action) == 'gitcommited' and isset($commiters[$action->actor])) $action->actor = $commiters[$action->actor];
$action->history = isset($histories[$actionID]) ? $histories[$actionID] : array();
$actions[$actionID] = $action;
}
@@ -605,7 +606,7 @@ class actionModel extends model
if($history->diff != '')
{
$history->diff = str_replace(array('<ins>', '</ins>', '<del>', '</del>'), array('[ins]', '[/ins]', '[del]', '[/del]'), $history->diff);
$history->diff = $history->field != 'subversion' ? htmlspecialchars($history->diff) : $history->diff; // Keep the diff link.
$history->diff = ($history->field != 'subversion' and $history->field != 'git') ? htmlspecialchars($history->diff) : $history->diff; // Keep the diff link.
$history->diff = str_replace(array('[ins]', '[/ins]', '[del]', '[/del]'), array('<ins>', '</ins>', '<del>', '</del>'), $history->diff);
$history->diff = nl2br($history->diff);
$history->noTagDiff = preg_replace('/&lt;\/?([a-z][a-z0-9]*)[^\/]*\/?&gt;/Ui', '', $history->diff);
+18 -6
View File
@@ -32,7 +32,7 @@ class git extends control
*/
public function diff($path, $revision)
{
$url = helper::safe64Decode($path);
$path = helper::safe64Decode($path);
$this->view->url = $path;
$this->view->revision = $revision;
$this->view->diff = $this->git->diff($path, $revision);
@@ -50,7 +50,7 @@ class git extends control
*/
public function cat($path, $revision)
{
$url = helper::safe64Decode($url);
$path = helper::safe64Decode($path);
$this->view->path = $path;
$this->view->revision = $revision;
$this->view->code = $this->git->cat($path, $revision);
@@ -69,12 +69,24 @@ class git extends control
if($this->post->logs)
{
$repoRoot = $this->post->repoRoot;
$logs = stripslashes($this->post->logs);
$logs = simplexml_load_string($logs);
foreach($logs->logentry as $entry)
$list = json_decode($this->post->logs);
$logs = array();
$i = 0;
foreach($list as $line)
{
$parsedLogs[] = $this->git->convertLog($entry);
if(!$line)
{
$i++;
continue;
}
$logs[$i][] = $line;
}
foreach($logs as $log)
{
$parsedLogs[] = $this->convertLog($log);
}
$parsedObjects = array('stories' => array(), 'tasks' => array(), 'bugs' => array());
foreach($parsedLogs as $log)
{
+16 -13
View File
@@ -98,6 +98,7 @@ class gitModel extends model
$this->printLog("get " . count($logs) . " logs");
$this->printLog('begin parsing logs');
$latestRevision = $logs[0]->revision;
foreach($logs as $log)
{
$this->printLog("parsing log {$log->revision}");
@@ -112,7 +113,7 @@ class gitModel extends model
if($objects)
{
$this->printLog('extract' .
'story:' . join(' ', $objects['stories']) .
' story:' . join(' ', $objects['stories']) .
' task:' . join(' ', $objects['tasks']) .
' bug:' . join(',', $objects['bugs']));
@@ -122,10 +123,10 @@ class gitModel extends model
{
$this->printLog('no objects found' . "\n");
}
if($log->revision > $savedRevision) $savedRevision = $log->revision;
}
$this->saveLastRevision($savedRevision);
$this->printLog("save revision $savedRevision");
$this->saveLastRevision($latestRevision);
$this->printLog("save revision $latestRevision");
$this->deleteRestartFile();
$this->printLog("\n\nrepo $name finished");
}
@@ -243,15 +244,16 @@ class gitModel extends model
/* The git log command. */
if($fromRevision)
{
$cmd = "cd $this->repoRoot; $this->client log --stat -r $fromRevision:HEAD --pretty=format:%an*_*%cd*_*%H*_*%s";
$cmd = "cd $this->repoRoot; $this->client log --stat $fromRevision..HEAD --pretty=format:%an*_*%cd*_*%H*_*%s";
}
else
{
$cmd = "cd $this->repoRoot; $this->client log --stat --pretty=format:%an*_*%cd*_*%H*_*%s";
}
exec($cmd, $list);
exec($cmd, $list, $return);
if(!$list) die("Some error occers: \nThe command is $cmd\n");
if(!$list and $return) die("Some error occers: \nThe command is $cmd\n");
if(!$list and !$return) exit;
/* Process logs. */
$logs = array();
@@ -296,7 +298,7 @@ class gitModel extends model
{
if(strpos($change, '|') === false) continue;
list($entry, $modify) = explode('|', $change);
$entry = trim($entry);
$entry = '/' . trim($entry);
$parsedLog->files['M'][] = $entry;
}
@@ -378,7 +380,7 @@ class gitModel extends model
$path = str_replace('%2F', '/', urlencode($path));
$path = str_replace('%3A', ':', $path);
$cmd = $this->client . " diff $revision^ $revision $url";
$cmd = "cd $repo->path;$this->client diff $revision^ $revision $path";
$diff = `$cmd`;
return $diff;
}
@@ -403,7 +405,8 @@ class gitModel extends model
$path = str_replace('%2F', '/', urlencode($path));
$path = str_replace('%3A', ':', $path);
$cmd = $this->client . " show -r $revision $path";
$subPath = substr($path, strlen($repo->path) + 1);
$cmd = "cd $repo->path;$this->client show $revision:$subPath";
$code = `$cmd`;
return $code;
}
@@ -437,7 +440,7 @@ class gitModel extends model
$action->action = 'gitcommited';
$action->date = $log->date;
$action->comment = $this->iconvComment($log->msg);
$action->extra = $log->revision;
$action->extra = substr($log->revision, 0, 10);
$changes = $this->createActionChanges($log, $repoRoot);
@@ -559,7 +562,7 @@ class gitModel extends model
$diff .= $action == 'M' ? "$diffLink\n" : "\n" ;
}
}
$changes->field = 'subversion';
$changes->field = 'git';
$changes->old = '';
$changes->new = '';
$changes->diff = trim($diff);
@@ -629,7 +632,7 @@ class gitModel extends model
{
if(!file_exists($this->logFile)) return 0;
if(file_exists($this->restartFile)) return 0;
return (int)trim(file_get_contents($this->logFile));
return trim(file_get_contents($this->logFile));
}
/**
+18 -7
View File
@@ -46,13 +46,14 @@ $lang->moduleOrder[125] = 'action';
$lang->moduleOrder[130] = 'mail';
$lang->moduleOrder[135] = 'svn';
$lang->moduleOrder[140] = 'search';
$lang->moduleOrder[145] = 'tree';
$lang->moduleOrder[150] = 'api';
$lang->moduleOrder[155] = 'file';
$lang->moduleOrder[160] = 'misc';
$lang->moduleOrder[165] = 'sso';
$lang->moduleOrder[170] = 'webapp';
$lang->moduleOrder[140] = 'git';
$lang->moduleOrder[145] = 'search';
$lang->moduleOrder[150] = 'tree';
$lang->moduleOrder[155] = 'api';
$lang->moduleOrder[160] = 'file';
$lang->moduleOrder[165] = 'misc';
$lang->moduleOrder[170] = 'sso';
$lang->moduleOrder[175] = 'webapp';
$lang->resource = new stdclass();
@@ -513,6 +514,16 @@ $lang->svn->methodOrder[5] = 'diff';
$lang->svn->methodOrder[10] = 'cat';
$lang->svn->methodOrder[15] = 'apiSync';
/* Git. */
$lang->resource->git = new stdclass();
$lang->resource->git->diff = 'diff';
$lang->resource->git->cat = 'cat';
$lang->resource->git->apiSync = 'apiSync';
$lang->git->methodOrder[5] = 'diff';
$lang->git->methodOrder[10] = 'cat';
$lang->git->methodOrder[15] = 'apiSync';
/* Company. */
$lang->resource->company = new stdclass();
$lang->resource->company->index = 'index';