diff --git a/db/update17.3.sql b/db/update17.3.sql index ab7a7fcb30..71a34bc665 100644 --- a/db/update17.3.sql +++ b/db/update17.3.sql @@ -2,7 +2,7 @@ ALTER TABLE `zt_mr` CHANGE COLUMN `gitlabID` `hostID` mediumint(8) UNSIGNED NOT ALTER TABLE `zt_mr` MODIFY COLUMN `sourceProject` varchar(50) NOT NULL AFTER `hostID`; ALTER TABLE `zt_mr` MODIFY COLUMN `targetProject` varchar(50) NOT NULL AFTER `sourceBranch`; UPDATE `zt_project` SET `status`='closed' WHERE `type` IN ('sprint', 'stage', 'kanban') AND `model`='' AND `status` = 'done'; -ALTER TABLE `zt_repo` ADD COLUMN `serviceHost` int(10) NOT NULL AFTER `client`; +ALTER TABLE `zt_repo` ADD COLUMN `serviceHost` varchar(50) NOT NULL AFTER `client`; ALTER TABLE `zt_repo` ADD COLUMN `serviceProject` varchar(100) NOT NULL AFTER `serviceHost`; UPDATE `zt_repo` SET `serviceHost` = `client`, `serviceProject` = `path` WHERE `SCM` = 'Gitlab'; UPDATE `zt_repo` SET `client` = '', `path` = '' WHERE `SCM` = 'Gitlab'; diff --git a/lib/scm/gitea.class.php b/lib/scm/gitea.class.php index a4256e3d2e..0aee01bfbf 100644 --- a/lib/scm/gitea.class.php +++ b/lib/scm/gitea.class.php @@ -21,7 +21,7 @@ class Gitea $this->client = $client; $this->root = rtrim($root, DIRECTORY_SEPARATOR); - $this->branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : ''; + $this->branch = isset($_COOKIE['repoBranch']) ? 'origin/' . $_COOKIE['repoBranch'] : ''; chdir($this->root); exec("{$this->client} config core.quotepath false"); @@ -127,7 +127,7 @@ class Gitea chdir($this->root); /* Get local branch. */ - $cmd = escapeCmd("$this->client branch -r"); + $cmd = escapeCmd("$this->client branch -a"); $list = execCmd($cmd . ' 2>&1', 'array', $result); if($result) return array(); @@ -139,10 +139,9 @@ class Gitea foreach($list as $localBranch) { $localBranch = trim($localBranch); - if(substr($localBranch, 0, 11) == 'origin/HEAD') continue; - + if(substr($localBranch, 0, 19) == 'remotes/origin/HEAD') continue; if(substr($localBranch, 0, 1) == '*') $localBranch = substr($localBranch, 1); - if(substr($localBranch, 0, 7) == 'origin/') $localBranch = substr($localBranch, 7); + if(substr($localBranch, 0, 15) == 'remotes/origin/') $localBranch = substr($localBranch, 15); $localBranch = trim($localBranch); if(empty($localBranch))continue; @@ -538,6 +537,8 @@ class Gitea $count = $count == 0 ? '' : "-n $count"; chdir($this->root); + if($branch) execCmd(escapeCmd("$this->client checkout $branch"), 'array'); + $list = execCmd(escapeCmd("$this->client log $count $revision -- ./"), 'array'); $commits = $this->parseLog($list); diff --git a/lib/scm/gitrepo.class.php b/lib/scm/gitrepo.class.php index 92729062cb..07235fda35 100644 --- a/lib/scm/gitrepo.class.php +++ b/lib/scm/gitrepo.class.php @@ -21,7 +21,7 @@ class GitRepo $this->client = $client; $this->root = rtrim($root, DIRECTORY_SEPARATOR); - $this->branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : ''; + $this->branch = isset($_COOKIE['repoBranch']) ? 'origin/' . $_COOKIE['repoBranch'] : ''; chdir($this->root); exec("{$this->client} config core.quotepath false"); @@ -127,17 +127,21 @@ class GitRepo chdir($this->root); /* Get local branch. */ - $cmd = escapeCmd("$this->client branch"); + $cmd = escapeCmd("$this->client branch -a"); $list = execCmd($cmd . ' 2>&1', 'array', $result); if($result) return array(); /* Get default branch. */ $defaultBranch = execCmd("$this->client symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'"); + $defaultBranch = trim($defaultBranch); $branches = array(); foreach($list as $localBranch) { + $localBranch = trim($localBranch); + if(substr($localBranch, 0, 19) == 'remotes/origin/HEAD') continue; if(substr($localBranch, 0, 1) == '*') $localBranch = substr($localBranch, 1); + if(substr($localBranch, 0, 15) == 'remotes/origin/') $localBranch = substr($localBranch, 15); $localBranch = trim($localBranch); if(empty($localBranch))continue; @@ -533,6 +537,8 @@ class GitRepo $count = $count == 0 ? '' : "-n $count"; chdir($this->root); + if($branch) execCmd(escapeCmd("$this->client checkout $branch"), 'array'); + $list = execCmd(escapeCmd("$this->client log $count $revision -- ./"), 'array'); $commits = $this->parseLog($list);