diff --git a/module/repo/model.php b/module/repo/model.php index 52a01b7781..b43d3d0ab1 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -2309,6 +2309,8 @@ class repoModel extends model public function updateCommitDate(int $repoID): void { $repo = $this->getByID($repoID); + if(empty($repo->id)) return; + if($repo->SCM == 'Gitlab') { $scm = $this->app->loadClass('scm'); diff --git a/module/repo/test/model/getlistbycondition.php b/module/repo/test/model/getlistbycondition.php new file mode 100644 index 0000000000..1a8a1f1c8e --- /dev/null +++ b/module/repo/test/model/getlistbycondition.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +getListByCondition(); +timeout=0 +cid=1 + +- 根据query查询 @0 +- query为空时查询第1条的name属性 @testHtml +- 排序条件查询属性id @1 +- 按分页查询属性id @3 + +*/ + +zdTable('repo')->config('repo')->gen(5); + +$repo = $tester->loadModel('repo'); +$repo->app->moduleName = 'repo'; +$repo->app->methodName = 'browse'; + +$repoQuery = "path like '%123%'"; +$orderBy = 'id_asc'; + +$pager = new stdclass(); +$pager->recPerPage = 2; +$pager->pageID = 2; +$repo->app->loadClass('pager', true); +$pager = pager::init(0, $pager->recPerPage, $pager->pageID); + +r($repo->getListByCondition($repoQuery, $SCM = 'Gitlab')) && p() && e('0'); //根据query查询 +r($repo->getListByCondition('', $SCM = 'Gitlab')) && p('1:name') && e('testHtml'); //query为空时查询 + +$result = $repo->getListByCondition('', $SCM = 'Gitlab', $orderBy); +r(array_shift($result)) && p('id') && e(1); //排序条件查询 + +$result = $repo->getListByCondition('', $SCM = 'Gitlab,Gitea', $orderBy, $pager); +r(array_shift($result)) && p('id') && e(3); //按分页查询 diff --git a/module/repo/test/model/updatecommitdate.php b/module/repo/test/model/updatecommitdate.php new file mode 100644 index 0000000000..0cd152152b --- /dev/null +++ b/module/repo/test/model/updatecommitdate.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +updateCommitDate(); +timeout=0 +cid=1 + +- 更新gitlab版本库属性lastCommit @2023-12-23 11:39:02 +- 更新gitea版本库属性lastCommit @~~ +- 更新空版本库 @return empty + +*/ + +zdTable('repo')->config('repo')->gen(5); + +$repo = new repoTest(); + +$gitlabID = 1; +$giteaID = 3; + +r($repo->updateCommitDateTest($gitlabID)) && p('lastCommit') && e('2023-12-23 11:39:02'); //更新gitlab版本库 +r($repo->updateCommitDateTest($giteaID)) && p('lastCommit') && e('~~'); //更新gitea版本库 +r($repo->updateCommitDateTest(0)) && p() && e('return empty'); //更新空版本库 \ No newline at end of file diff --git a/module/repo/test/repo.class.php b/module/repo/test/repo.class.php index 038a955821..157ecf69b9 100644 --- a/module/repo/test/repo.class.php +++ b/module/repo/test/repo.class.php @@ -344,6 +344,16 @@ class repoTest return $this->objectModel->getByID($repoID); } + public function updateCommitDateTest(int $repoID) + { + $this->objectModel->updateCommitDate($repoID); + + if(dao::isError()) return dao::getError(); + + $repo = $this->objectModel->getByID($repoID); + return !empty($repo->id) ? $repo : 'return empty'; + } + public function getUnsyncedCommitsTest(int $repoID) { global $dao;