From 06ea240028cc0473639857aecfd7e8f3abd59df2 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 28 May 2024 15:47:03 +0800 Subject: [PATCH] * [bug#50302,0.3h] adjust branch commit sync logic. --- module/repo/control.php | 35 +++++++++++++++++----------------- module/repo/js/browse.ui.js | 5 +++++ module/repo/ui/browse.html.php | 3 ++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/module/repo/control.php b/module/repo/control.php index 281a242226..fe5a03911a 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -505,23 +505,24 @@ class repo extends control /* Synchronous commit only in root path. */ if(in_array($repo->SCM, $this->config->repo->gitTypeList) && $repo->SCM != 'Gitlab' && empty($path) && $infos && empty($revisions)) $this->locate($this->repo->createLink('showSyncCommit', "repoID=$repoID&objectID=$objectID&branch=" . helper::safe64Encode(base64_encode($this->cookie->repoBranch)))); - $this->view->title = $this->lang->repo->common; - $this->view->repo = $repo; - $this->view->revisions = $revisions; - $this->view->revision = $revision; - $this->view->lastRevision = $lastRevision; - $this->view->infos = $infos; - $this->view->repoID = $repoID; - $this->view->branches = $branches; - $this->view->tags = $tags; - $this->view->branchID = $branchID; - $this->view->objectID = $objectID; - $this->view->pager = $pager; - $this->view->path = urldecode($path); - $this->view->logType = $type; - $this->view->cloneUrl = $this->repo->getCloneUrl($repo); - $this->view->repoPairs = $this->repo->getRepoPairs($this->app->tab, $objectID); - $this->view->branchOrTag = $branchOrTag; + $this->view->title = $this->lang->repo->common; + $this->view->repo = $repo; + $this->view->revisions = $revisions; + $this->view->revision = $revision; + $this->view->lastRevision = $lastRevision; + $this->view->infos = $infos; + $this->view->repoID = $repoID; + $this->view->branches = $branches; + $this->view->tags = $tags; + $this->view->branchID = $branchID; + $this->view->base64BranchID = $base64BranchID; + $this->view->objectID = $objectID; + $this->view->pager = $pager; + $this->view->path = urldecode($path); + $this->view->logType = $type; + $this->view->cloneUrl = $this->repo->getCloneUrl($repo); + $this->view->repoPairs = $this->repo->getRepoPairs($this->app->tab, $objectID); + $this->view->branchOrTag = $branchOrTag; $this->display(); } diff --git a/module/repo/js/browse.ui.js b/module/repo/js/browse.ui.js index 84d1e8a20b..2420bef83d 100644 --- a/module/repo/js/browse.ui.js +++ b/module/repo/js/browse.ui.js @@ -282,3 +282,8 @@ window.afterPageUpdate = function() }); }, 200); }; + +$(function() +{ + if(base64BranchID) $.get($.createLink('repo', 'ajaxSyncBranchCommit', 'repoID=' + repo.id + '&branch=' + base64BranchID)); +}); diff --git a/module/repo/ui/browse.html.php b/module/repo/ui/browse.html.php index a41b017c77..1617b4e229 100644 --- a/module/repo/ui/browse.html.php +++ b/module/repo/ui/browse.html.php @@ -13,6 +13,7 @@ declare(strict_types=1); namespace zin; jsVar('copied', $lang->repo->copied); +jsVar('base64BranchID', $base64BranchID); $module = $app->tab == 'devops' ? 'repo' : $app->tab; dropmenu @@ -212,7 +213,7 @@ toolbar ( a( set::className('last-sync-time'), - set::href($lastRevision->link), + empty($lastRevision->link) ? null : set::href($lastRevision->link), $lang->repo->notice->lastSyncTime . (isset($lastRevision->time) ? date('m-d H:i', strtotime($lastRevision->time)) : date('m-d H:i')) ), !in_array($repo->SCM, $config->repo->notSyncSCM) ? item(set($refreshItem)) : null,