From cd50412c19bbcb95edce08d1a12afe5a26c06fd5 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Mon, 18 Dec 2023 15:48:21 +0800 Subject: [PATCH] * Adjust scm check rule for file tree get. --- module/repo/control.php | 2 +- module/repo/model.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/module/repo/control.php b/module/repo/control.php index 03b3f4550f..e92dd2e367 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -2002,7 +2002,7 @@ class repo extends control $repo = $this->repo->getByID($repoID); if($path) $path = helper::safe64Decode($path); - if($repo->SCM == 'gitlab') return print(json_encode($this->repo->getGitlabFilesByPath($repo, $path, $branch))); + if($repo->SCM == 'Gitlab') return print(json_encode($this->repo->getGitlabFilesByPath($repo, $path, $branch))); return print(json_encode($this->repoZen->getViewTree($repo, $path, $branch))); } } diff --git a/module/repo/model.php b/module/repo/model.php index 81bf6926d4..27216235d7 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -2170,7 +2170,15 @@ class repoModel extends model $service = $this->loadModel('pipeline')->getByID($repo->serviceHost); if($repo->SCM == 'Gitlab') { - if($getCodePath) $project = $this->loadModel('gitlab')->apiGetSingleProject($repo->serviceHost, $repo->serviceProject); + if($getCodePath) + { + $project = $this->loadModel('gitlab')->apiGetSingleProject((int)$repo->serviceHost, (int)$repo->serviceProject); + if(isset($project->web_url) && $repo->path != $project->web_url) + { + $repo->path = $project->web_url; + $this->dao->update(TABLE_REPO)->set('path')->eq($repo->path)->where('id')->eq($repo->id)->exec(); + } + } $repo->path = (!$repo->path && $service) ? sprintf($this->config->repo->{$service->type}->apiPath, $service->url, $repo->serviceProject) : $repo->path; $repo->apiPath = sprintf($this->config->repo->{$service->type}->apiPath, $service->url, $repo->serviceProject);