* Optimize gitlab sync process.

This commit is contained in:
zenggang
2023-09-22 03:04:08 +00:00
parent 6411ea131f
commit d97605e68d
12 changed files with 245 additions and 60 deletions
+2
View File
@@ -558,3 +558,5 @@ INSERT INTO `zt_metric`(`purpose`, `scope`, `object`, `stage`, `name`, `code`, `
INSERT INTO `zt_metric`(`purpose`, `scope`, `object`, `stage`, `name`, `code`, `unit`, `desc`, `definition`, `when`, `event`, `cronCFG`, `time`, `createdBy`, `createdDate`, `editedBy`, `editedDate`, `order`, `deleted`) VALUES ('scale', 'user', 'feedback', 'released', '按人员统计的待处理反馈数', 'count_of_assigned_feedback_in_user', 'count', '按人员统计的待处理反馈数表示每个人待处理的反馈数量之和。反映了每个人需要处理的反馈数量上的规模。该数值越大,说明需要投入越多的时间处理反馈。', '所有反馈个数求和\n指派给为某人\n过滤已删除的反馈\n过滤已删除产品的反馈', 'realtime', '', '', '', 'system', '2023-08-22 08:00:00', '', NULL, 0, '0');
INSERT INTO `zt_metric`(`purpose`, `scope`, `object`, `stage`, `name`, `code`, `unit`, `desc`, `definition`, `when`, `event`, `cronCFG`, `time`, `createdBy`, `createdDate`, `editedBy`, `editedDate`, `order`, `deleted`) VALUES ('scale', 'user', 'feedback', 'released', '按人员统计的待评审反馈数', 'count_of_reviewing_feedback_in_user', 'count', '按人员统计的待评审反馈数表示每个人待评审的反馈数量之和。反映了每个人需要评审的反馈的规模。该数值越大,说明需要投入越多的时间评审反馈。', '所有反馈个数求和\n状态为待评审\n指派给为某人\n过滤已删除的反馈\n过滤已删除产品的反馈', 'realtime', '', '', '', 'system', '2023-08-22 08:00:00', '', NULL, 0, '0');
INSERT INTO `zt_metric`(`purpose`, `scope`, `object`, `stage`, `name`, `code`, `unit`, `desc`, `definition`, `when`, `event`, `cronCFG`, `time`, `createdBy`, `createdDate`, `editedBy`, `editedDate`, `order`, `deleted`) VALUES ('scale', 'user', 'feedback', 'released', '按人员统计的每日评审反馈数', 'count_of_daily_review_feedback_in_user', 'count', '按人员统计的日评审反馈数表示每个人每日评审的反馈数量之和。反映了每个人每日评审的反馈的规模。该数值越大,说明工作量越大。', '所有反馈个数求和\n由谁评审为某人\n评审时间为某日\n过滤已删除的反馈\n过滤已删除产品的反馈', 'realtime', '', '', '', 'system', '2023-08-22 08:00:00', '', NULL, 0, '0');
ALTER TABLE `zt_repo` ADD `lastCommit` DATETIME NULL DEFAULT NULL AFTER `lastSync`;
+6 -6
View File
@@ -575,7 +575,7 @@ class gitlab
$log->time = date('Y-m-d H:i:s', strtotime($commit->created_at));
$commits[$commit->id] = $log;
$files[$commit->id] = $this->getFilesByCommit($log->revision);
if($getFile) $files[$commit->id] = $this->getFilesByCommit($log->revision);
return array('commits' => $commits, 'files' => $files);
}
@@ -659,7 +659,7 @@ class gitlab
* @access public
* @return array
*/
public function getCommitsByPath($path, $fromRevision = '', $toRevision = '', $perPage = 0, $page = 1, $getUrl = false)
public function getCommitsByPath($path, $fromRevision = '', $toRevision = '', $perPage = 0, $page = 1, $getUrl = false, $beginDate = '', $endDate = '')
{
$path = ltrim($path, DIRECTORY_SEPARATOR);
$api = "commits";
@@ -668,17 +668,17 @@ class gitlab
$param->path = urldecode($path);
$param->ref_name = ($toRevision != 'HEAD' and $toRevision) ? $toRevision : $this->branch;
$fromDate = $this->getCommittedDate($fromRevision);
$toDate = $this->getCommittedDate($toRevision);
$fromDate = $beginDate ? $beginDate : $this->getCommittedDate($fromRevision);
$toDate = $endDate ? $endDate : $this->getCommittedDate($toRevision);
$since = '';
$until = '';
if($fromRevision and $toRevision)
if(($fromRevision && $toRevision) || ($beginDate && $endDate))
{
$since = min($fromDate, $toDate);
$until = max($fromDate, $toDate);
}
elseif($fromRevision)
elseif($fromRevision || $beginDate)
{
$since = $fromDate;
}
+16 -17
View File
@@ -339,8 +339,17 @@ class design extends control
* @access public
* @return void
*/
public function linkCommit($designID = 0, $repoID = 0, $begin = '', $end = '', $recTotal = 0, $recPerPage = 50, $pageID = 1)
public function linkCommit(int $designID = 0, int $repoID = 0, string $begin = '', string $end = '', int $recTotal = 0, int $recPerPage = 50, int $pageID = 1)
{
if($_POST)
{
$this->design->linkCommit($designID, $repoID);
$result['result'] = 'success';
$result['message'] = $this->lang->saveSuccess;
$result['locate'] = 'parent';
return $this->send($result);
}
$design = $this->design->getById($designID);
$productID = $this->commonAction($design->project, $design->product, $designID);
@@ -355,16 +364,7 @@ class design extends control
$repo = $this->loadModel('repo')->getByID($repoID);
$revisions = $this->repo->getCommits($repo, '', 'HEAD', '', '', $begin, date('Y-m-d 23:59:59', strtotime($end)));
if($_POST)
{
$this->design->linkCommit($designID, $repoID);
$result['result'] = 'success';
$result['message'] = $this->lang->saveSuccess;
$result['locate'] = 'parent';
return $this->send($result);
}
$this->session->set('designRevisions', $revisions);
/* Linked submission. */
$linkedRevisions = array();
@@ -435,14 +435,13 @@ class design extends control
*/
public function viewCommit($designID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$design = $this->design->getByID($designID);
$design = $this->design->getCommit($designID, $pager);
$productID = $this->commonAction($design->project, $design->product, $designID);
/* Init pager. */
$this->app->loadClass('pager', $static = true);
$pager = pager::init(0, $recPerPage, $pageID);
$pager = pager::init(0, $recPerPage, $pageID);
$design = $this->design->getCommit($designID, $pager);
$this->view->title = $this->lang->design->common . $this->lang->colon . $this->lang->design->submission;
$this->view->position[] = $this->lang->design->submission;
@@ -463,10 +462,10 @@ class design extends control
* @access public
* @return void
*/
public function revision($repoID = 0, $projectID = 0)
public function revision($revisionID = 0, $projectID = 0)
{
$repo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('id')->eq($repoID)->fetch();
$repoURL = $this->createLink('repo', 'revision', "repoID=$repo->repo&objectID=$projectID&revistion=$repo->revision");
$revision = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('id')->eq($revisionID)->fetch();
$repoURL = $this->createLink('repo', 'revision', "repoID=$revision->repo&objectID=$projectID&revistion=$revision->revision");
header("location:" . $repoURL);
}
+23 -3
View File
@@ -173,10 +173,31 @@ class designModel extends model
* @access public
* @return void
*/
public function linkCommit($designID = 0, $repoID = 0)
public function linkCommit(int $designID = 0, int $repoID = 0)
{
$repo = $this->loadModel('repo')->getByID($repoID);
$revisions = $_POST['revision'];
if($repo->SCM == 'Gitlab')
{
$logs = array();
foreach($this->session->designRevisions as $key => $commit)
{
if(in_array($commit->revision, $revisions))
{
$log = new stdclass();
$log->committer = $commit->committer_name;
$log->revision = $commit->id;
$log->comment = $commit->message;
$log->time = date('Y-m-d H:i:s', strtotime($commit->created_at));
$logs[] = $log;
}
}
$this->repo->saveCommit($repoID, array('commits' => $logs), 0);
$revisions = $this->dao->select('id')->from(TABLE_REPOHISTORY)->where('revision')->in($revisions)->andWhere('repo')->eq($repoID)->fetchPairs('id');
}
foreach($revisions as $revision)
{
$data = new stdclass();
@@ -247,10 +268,9 @@ class designModel extends model
$design->files = $this->loadModel('file')->getByObject('design', $designID);
$design->productName = $design->product ? $this->dao->findByID($design->product)->from(TABLE_PRODUCT)->fetch('name') : $this->lang->product->all;
$design->commit = '';
$relations = $this->loadModel('common')->getRelations('design', $designID, 'commit');
foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "repoID=$relation->BID&projectID={$design->project}"), "#$relation->BID");
foreach($relations as $relation) $design->commit .= html::a(helper::createLink('design', 'revision', "revisionID=$relation->BID&projectID={$design->project}"), "#$relation->BID");
return $this->loadModel('file')->replaceImgURL($design, 'desc');
}
+9 -1
View File
@@ -40,9 +40,16 @@
</tr>
</thead>
<tbody>
<?php
if($_GET['onlybody'] == 'yes')
{
$_GET['onlybody'] = 'no';
$changeOnlyBody = true;
}
?>
<?php foreach($design->commit as $commit):?>
<tr>
<td title="<?php echo $commit->id;?>"><?php echo html::a(helper::createLink('design', 'revision', "repoID=$commit->id"), "#$commit->id", '_blank');?></td>
<td title="<?php echo $commit->id;?>"><?php echo html::a(helper::createLink('design', 'revision', "repoID={$commit->id}&projectID={$design->project}"), "#$commit->id", '_blank');?></td>
<td><?php echo zget($users, $commit->committer, $commit->committer);?></td>
<td><?php echo substr($commit->time, 0, 11);?></td>
<td title="<?php echo $commit->comment;?>"><?php echo $commit->comment;?></td>
@@ -51,6 +58,7 @@
</td>
</tr>
<?php endforeach;?>
<?php if($changeOnlyBody) $_Get['onlybody'] = 'yes'?>
</tbody>
</table>
<div class='table-footer table-statistic'>
+9 -1
View File
@@ -69,6 +69,8 @@ class gitModel extends model
/* Get repos and load module. */
$this->setRepos();
$this->loadModel('job');
$this->loadModel('gitlab');
$this->loadModel('repo');
if(empty($this->repos)) return false;
@@ -82,7 +84,11 @@ class gitModel extends model
{
$this->updateCommit($repo, $commentGroup, true);
if($repo->SCM == 'Gitlab') $this->loadModel('gitlab')->updateCodePath((int)$repo->serviceHost, (int)$repo->serviceProject, (int)$repo->id);
if($repo->SCM == 'Gitlab')
{
$this->gitlab->updateCodePath((int)$repo->serviceHost, (int)$repo->serviceProject, (int)$repo->id);
$this->repo->updateCommitDate((int)$repo->id);
}
/* Create compile by tag. */
$jobs = zget($tagGroup, $repoID, array());
@@ -120,6 +126,8 @@ class gitModel extends model
*/
public function updateCommit($repo, $commentGroup, $printLog = true)
{
if($repo->SCM == 'Gitlab') return;
/* Load module and print log. */
$this->loadModel('repo');
if($printLog) $this->printLog("begin repo $repo->id");
+4 -3
View File
@@ -400,11 +400,11 @@ class gitlabModel extends model
* @access public
* @return array
*/
public function getCommits($repo, $entry, $revision = 'HEAD', $type = 'dir', $pager = null, $begin = 0, $end = 0)
public function getCommits($repo, $entry, $revision = 'HEAD', $type = 'dir', $pager = null, $begin = '', $end = '')
{
$scm = $this->app->loadClass('scm');
$scm->setEngine($repo);
$comments = $scm->engine->getCommitsByPath($entry, '', '', isset($pager->recPerPage) ? $pager->recPerPage : 10, isset($pager->pageID) ? $pager->pageID : 1);
$comments = $scm->engine->getCommitsByPath($entry, '', '', isset($pager->recPerPage) ? $pager->recPerPage : 10, isset($pager->pageID) ? $pager->pageID : 1, false, $begin, $end);
if(!is_array($comments)) return array();
if(isset($pager->recTotal)) $pager->recTotal = count($comments) < $pager->recPerPage ? $pager->recPerPage * $pager->pageID : $pager->recPerPage * ($pager->pageID + 1);
@@ -1252,12 +1252,13 @@ class gitlabModel extends model
* @access public
* @return bool
*/
public function addPushWebhook($repo)
public function addPushWebhook($repo, $token = '')
{
$hook = new stdClass;
$hook->url = common::getSysURL() . '/api.php/v1/gitlab/webhook?repoID='. $repo->id;
$hook->push_events = true;
$hook->merge_requests_events = true;
if($token) $hook->token = $token;
/* Return an empty array if where is one existing webhook. */
if($this->isWebhookExists($repo, $hook->url)) return array();
+25 -19
View File
@@ -156,8 +156,8 @@ class repo extends control
{
/* Add webhook. */
$repo = $this->repo->getByID($repoID);
$this->loadModel('gitlab')->addPushWebhook($repo);
$this->gitlab->updateCodePath($repo->serviceHost, $repo->serviceProject, $repo->id);
$this->repo->updateCommitDate($repoID);
}
$this->loadModel('action')->create('repo', $repoID, 'created');
@@ -631,6 +631,8 @@ class repo extends control
$item->revision = $repo->SCM != 'Subversion' ? substr($item->revision, 0, 10) : $item->revision;
}
if($path == '') $this->repoZen->updateLastCommit($repo, $lastRevision);
/* Get files info. */
$infos = $this->repoZen->getFilesInfo($repo, $path, $branchID, $refresh, $revision, $lastRevision);
@@ -1062,6 +1064,7 @@ class repo extends control
$latestInDB = $this->repo->getLatestCommit($repoID);
$this->view->version = $latestInDB ? (int)$latestInDB->commit : 1;
$this->view->repoID = $repoID;
$this->view->repo = $this->repo->getByID($repoID);
$this->view->objectID = $objectID;
$this->view->branch = $branch;
$this->view->browseLink = $this->repo->createLink('browse', "repoID=" . ($this->app->tab == 'devops' ? $repoID : '') . "&branchID=" . helper::safe64Encode(base64_encode($branch)) . "&objectID=$objectID", '', false) . "#app={$this->app->tab}";
@@ -1490,25 +1493,28 @@ class repo extends control
}
}
$latestInDB = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.repo')->eq($repoID)
->beginIF($repo->SCM == 'Git' and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->beginIF($repo->SCM == 'Gitlab' and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->orderBy('t1.time')
->limit(1)
->fetch();
$logs = array();
if($repo->SCM != 'Gitlab')
{
$latestInDB = $this->dao->select('t1.*')->from(TABLE_REPOHISTORY)->alias('t1')
->leftJoin(TABLE_REPOBRANCH)->alias('t2')->on('t1.id=t2.revision')
->where('t1.repo')->eq($repoID)
->beginIF($repo->SCM == 'Git' and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->beginIF($repo->SCM == 'Gitlab' and $this->cookie->repoBranch)->andWhere('t2.branch')->eq($this->cookie->repoBranch)->fi()
->orderBy('t1.time')
->limit(1)
->fetch();
$version = empty($latestInDB) ? 1 : $latestInDB->commit + 1;
$logs = array();
$revision = $version == 1 ? 'HEAD' : (in_array($repo->SCM, array('Git', 'Gitea', 'Gogs')) ? $latestInDB->commit : $latestInDB->revision);
if($type == 'batch')
{
$logs = $this->scm->getCommits($revision, $this->config->repo->batchNum, $branchID);
}
else
{
$logs = $this->scm->getCommits($revision, 0, $branchID);
$version = empty($latestInDB) ? 1 : $latestInDB->commit + 1;
$revision = $version == 1 ? 'HEAD' : (in_array($repo->SCM, array('Git', 'Gitea', 'Gogs')) ? $latestInDB->commit : $latestInDB->revision);
if($type == 'batch')
{
$logs = $this->scm->getCommits($revision, $this->config->repo->batchNum, $branchID);
}
else
{
$logs = $this->scm->getCommits($revision, 0, $branchID);
}
}
$commitCount = $this->repo->saveCommit($repoID, $logs, $version, $branchID);
+132 -7
View File
@@ -203,8 +203,15 @@ class repoModel extends model
if($lastSubmitTime)
{
$lastRevision = $this->repoTao->getLastRevision($repo->id);
$repo->lastSubmitTime = isset($lastRevision->time) ? $lastRevision->time : '';
if($repo->lastCommit)
{
$repo->lastSubmitTime = $repo->lastCommit;
}
else
{
$lastRevision = $this->repoTao->getLastRevision($repo->id);
$repo->lastSubmitTime = isset($lastRevision->time) ? $lastRevision->time : '';
}
}
if(in_array(strtolower($repo->SCM), $this->config->repo->gitServiceList)) $repo = $this->processGitService($repo, $getCodePath);
@@ -277,10 +284,27 @@ class repoModel extends model
->exec();
if(dao::isError()) return false;
$repoID = $this->dao->lastInsertID();
$repo = $this->getByID($repoID);
if($repo->SCM == 'Gitlab')
{
$token = time();
$res = $this->loadModel('gitlab')->addPushWebhook($repo, $token);
if($res === false)
{
$thi->dao->delete()->from(TABLE_REPO)->where('id')->eq($repoID)->exec();
dao::$errors['webhook'][] = $this->lang->gitlab->failCreateWebhook;
return false;
}
else
{
$this->dao->update(TABLE_REPO)->set('password')->eq($token)->where('id')->eq($repoID)->exec();
}
}
$this->rmClientVersionFile();
return $this->dao->lastInsertID();
return $repoID;
}
/**
@@ -392,6 +416,24 @@ class repoModel extends model
}
}
if(($repo->serviceHost != $data->serviceHost || $repo->serviceProject != $data->serviceProject) && $data->SCM == 'Gitlab')
{
$repo->gitService = $data->serviceHost;
$repo->project = $data->serviceProject;
$token = time();
$res = $this->loadModel('gitlab')->addPushWebhook($repo, $token);
if($res === false)
{
dao::$errors['webhook'][] = $this->lang->gitlab->failCreateWebhook;
return false;
}
else
{
$data->password = $token;
}
}
if($data->encrypt == 'base64') $data->password = base64_encode($data->password);
$this->dao->update(TABLE_REPO)->data($data, 'serviceToken')
->batchCheck($this->config->repo->edit->requiredFields, 'notempty')
@@ -409,6 +451,7 @@ class repoModel extends model
{
$this->loadModel('gitlab')->updateCodePath($data->serviceHost, $data->serviceProject, $repo->id);
$data->path = $this->getByID($id)->path;
$this->updateCommitDate($repo->id);
}
if($repo->path != $data->path)
@@ -440,10 +483,28 @@ class repoModel extends model
if($type == 'task') $links = $this->post->tasks;
$revisionInfo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->andWhere('revision')->eq($revision)->fetch();
if(empty($revisionInfo)) $this->updateCommit($repoID);
if(empty($revisionInfo))
{
$repo = $this->getByID($repoID);
if($repo->SCM == 'Gitlab')
{
$scm = $this->app->loadClass('scm');
$scm->setEngine($repo);
$logs = $scm->getCommits($revision, 1);
$this->saveCommit($repoID, $logs, 0);
}
else
{
$this->updateCommit($repoID);
}
}
$revisionInfo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->andWhere('revision')->eq($revision)->fetch();
if(empty($revisionInfo)) return false;
if(empty($revisionInfo))
{
dao::$errors = $this->lang->fail;
return false;
}
$revisionID = $revisionInfo->id;
$committer = $this->dao->select('account')->from(TABLE_USER)->where('commiter')->eq($revisionInfo->committer)->fetch('account');
@@ -858,6 +919,11 @@ class repoModel extends model
return $branches;
}
public function getCommitsByRevisions($revisions)
{
return $this->dao->select('id')->from(TABLE_REPOHISTORY)->where('revision')->in($revisions)->fetchPairs('id');
}
/**
* Get commits.
*
@@ -874,7 +940,7 @@ class repoModel extends model
public function getCommits($repo, $entry, $revision = 'HEAD', $type = 'dir', $pager = null, $begin = 0, $end = 0)
{
if(!isset($repo->id)) return array();
if($repo->SCM == 'Gitlab' && !$begin && !$end) return $this->loadModel('gitlab')->getCommits($repo, $entry, $revision, $type, $pager, $begin, $end);
if($repo->SCM == 'Gitlab') return $this->loadModel('gitlab')->getCommits($repo, $entry, $revision, $type, $pager, $begin, $end);
$entry = ltrim($entry, '/');
$entry = $repo->prefix . (empty($entry) ? '' : '/' . $entry);
@@ -2340,7 +2406,40 @@ class repoModel extends model
{
/* Update code commit history. */
$commentGroup = $this->loadModel('job')->getTriggerGroup('commit', array($repo->id));
$this->loadModel('git')->updateCommit($repo, $commentGroup, false);
if($repo->SCM == 'Gitlab')
{
$this->loadModel('repo');
$jobs = zget($commentGroup, $repo->id, array());
$accountPairs = array();
$userList = $this->loadModel('gitlab')->apiGetUsers($repo->gitService);
$acountIDPairs = $this->gitlab->getUserIdAccountPairs($repo->gitService);
foreach($userList as $gitlabUser) $accountPairs[$gitlabUser->realname] = zget($acountIDPairs, $gitlabUser->id, '');
foreach($data->commits as $commit)
{
$log = new stdclass();
$log->revision = $commit->id;
$log->msg = $commit->message;
$log->author = $commit->author->name;
$log->date = date("Y-m-d H:i:s", strtotime($commit->timestamp));
$objects = $this->repo->parseComment($log->msg);
$this->repo->saveAction2PMS($objects, $log, $repo->path, $repo->encoding, 'git', $accountPairs);
foreach($jobs as $job)
{
foreach(explode(',', $job->comment) as $comment)
{
if(strpos($log->msg, $comment) !== false) $this->loadModel('job')->exec($job->id);
}
}
}
}
else
{
$this->loadModel('git')->updateCommit($repo, $commentGroup, false);
}
}
}
@@ -3028,6 +3127,7 @@ class repoModel extends model
public function updateCommit($repoID, $objectID = 0, $branchID = 0)
{
$repo = $this->getByID($repoID);
if($repo->SCM == 'Gitlab') return;
/* Update code commit history. */
$commentGroup = $this->loadModel('job')->getTriggerGroup('commit', array($repoID));
@@ -3155,4 +3255,29 @@ class repoModel extends model
return false;
}
/**
* 更新版本库最后提交时间。
* Update repo last commited date.
*
* @param int $repoID
* @access public
* @return void
*/
public function updateCommitDate(int $repoID): void
{
$repo = $this->getByID($repoID);
if($repo->SCM == 'Gitlab')
{
$scm = $this->app->loadClass('scm');
$scm->setEngine($repo);
$commits = $scm->engine->getCommitsByPath('', '', '', 1, 1);
$commit = $commits[0];
if(!empty($commit->committed_date))
{
$lastCommitDate = date('Y-m-d H:i:s', strtotime($commit->committed_date));
$this->dao->update(TABLE_REPO)->set('lastCommit')->eq($lastCommitDate)->where('id')->eq($repoID)->exec();
}
}
}
}
+2 -2
View File
@@ -80,7 +80,6 @@ if($fileName) $breadcrumbItems[] = h::span($fileName);
$app->tab == 'project' ? dropmenu
(
set::id('repoDropmenu'),
set::module('repo'),
set::text($repo->name),
set::url(createLink('repo', 'ajaxGetDropMenu', "repoID={$repo->id}&module=repo&method=browse&projectID={$objectID}"))
) : null,
@@ -209,7 +208,7 @@ toolbar
set::className('last-sync-time'),
$lang->repo->notice->lastSyncTime . $cacheTime
),
item(set($refreshItem)),
$repo->SCM != 'Gitlab' ? item(set($refreshItem)) : null,
dropdown
(
set::staticMenu(true),
@@ -257,6 +256,7 @@ jsVar('sortLink', helper::createLink('repo', 'browse', "repoID={$repoID}&recTota
/* Disbale check all checkbox of table header */
$config->repo->commentDtable->fieldList['id']['checkbox'] = jsRaw('(rowID) => rowID !== \'HEADER\'');
if($repo->SCM == 'Gitlab') unset($config->repo->commentDtable->fieldList['commit']);
$commentsTableData = initTableData($revisions, $config->repo->commentDtable->fieldList, $this->repo);
$readAllLink = $this->repo->createLink('log', "repoID=$repoID&objectID=$objectID&entry=" . $encodePath . "&revision=HEAD&type=$logType");
+1 -1
View File
@@ -40,7 +40,7 @@ div
(
h3($lang->repo->notice->syncing),
div(setClass('sync-line')),
p($lang->repo->notice->syncedCount, span($version, set::id('commits')))
$repo->SCM != 'Gitlab' ? p($lang->repo->notice->syncedCount, span($version, set::id('commits'))) : null
)
)
)
+16
View File
@@ -424,5 +424,21 @@ class repoZen extends repo
return array('branchMenus' => $branchMenus, 'tagMenus' => $tagMenus, 'selected' => $selected);
}
/**
* 更新版本库最后提交时间。
* Update repo last commited date.
*
* @param object $repo
* @param object $lastRevision
* @access protected
* @return void
*/
protected function updateLastCommit(object $repo, object $lastRevision): void
{
if(empty($lastRevision->committed_date)) return;
$lastCommitDate = date('Y-m-d H:i:s', strtotime($lastRevision->committed_date));
if(empty($repo->lastCommit) || $lastCommitDate > $repo->lastCommit) $this->dao->update(TABLE_REPO)->set('lastCommit')->eq($lastCommitDate)->where('id')->eq($repo->id)->exec();
}
}