From 24d032fd92dda9b89a8255243c8b59304319baf2 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Wed, 27 Jul 2022 08:48:08 +0800 Subject: [PATCH] * Modify tag get. --- lib/scm/gitea.class.php | 9 ++++++++- lib/scm/gitrepo.class.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/scm/gitea.class.php b/lib/scm/gitea.class.php index 26a1b3a3b9..d64adf54d9 100644 --- a/lib/scm/gitea.class.php +++ b/lib/scm/gitea.class.php @@ -21,7 +21,14 @@ class Gitea $this->client = $client; $this->root = rtrim($root, DIRECTORY_SEPARATOR); - $this->branch = isset($_COOKIE['repoBranch']) ? 'origin/' . $_COOKIE['repoBranch'] : ''; + + $branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : ''; + if($branch) + { + $branches = $this->branch(); + if(isset($branches[$branch])) $branch = "origin/$branch"; + } + $this->branch = $branch; chdir($this->root); exec("{$this->client} config core.quotepath false"); diff --git a/lib/scm/gitrepo.class.php b/lib/scm/gitrepo.class.php index 1e947489ad..bb39bcb417 100644 --- a/lib/scm/gitrepo.class.php +++ b/lib/scm/gitrepo.class.php @@ -21,7 +21,14 @@ class GitRepo $this->client = $client; $this->root = rtrim($root, DIRECTORY_SEPARATOR); - $this->branch = isset($_COOKIE['repoBranch']) ? 'origin/' . $_COOKIE['repoBranch'] : ''; + + $branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : ''; + if($branch) + { + $branches = $this->branch(); + if(isset($branches[$branch])) $branch = "origin/$branch"; + } + $this->branch = $branch; chdir($this->root); exec("{$this->client} config core.quotepath false");