diff --git a/public_html/api/index.php b/public_html/api/index.php index 74a9f2928335ca608a925f929adba69ba048235b..c84e9617d90ec202aa429c8d3e495954c00e63c6 100644 --- a/public_html/api/index.php +++ b/public_html/api/index.php @@ -10,6 +10,7 @@ * * ---------------------------------------------------------------------- * 2020-06-16 v0.9 <axel.hahn@iml.unibe.ch> + * 2021-03-29 v1.2 <axel.hahn@iml.unibe.ch> support slashes in branch names * ====================================================================== */ @@ -132,11 +133,11 @@ $aUriSplit= explode('/', preg_replace('/\?.*$/', '', $_SERVER["REQUEST_URI"])); array_shift($aUriSplit); - array_shift($aUriSplit); + array_shift($aUriSplit); _wd('<pre>$aUriSplit: '.print_r($aUriSplit, 1).'</pre>'); /* - /api/v1/projects/ci/build?auth=123 + /api/v1/projects/ci/build/... $aUriSplit: Array ( [0] => v1 @@ -173,11 +174,14 @@ $sPrjId = isset($aUriSplit[2]) ? $aUriSplit[2] : false; $sPrjAction = isset($aUriSplit[3]) ? $aUriSplit[3] : false; - $sParam4 = isset($aUriSplit[4]) ? $aUriSplit[4] : false; - $sParam5 = isset($aUriSplit[5]) ? $aUriSplit[5] : false; + $sBranch = implode('/', array_slice($aUriSplit, 4)); + + // $sParam4 = isset($aUriSplit[4]) ? $aUriSplit[4] : false; + // $sParam5 = isset($aUriSplit[5]) ? $aUriSplit[5] : false; $sMethod = $_SERVER['REQUEST_METHOD']; _wd('$sPrjId = '.$sPrjId); _wd('$sPrjAction = '.$sPrjAction); + _wd('$sBranch = ' . $sBranch); $oCLog = new logger(); // try to init the given project @@ -208,8 +212,8 @@ switch($sPrjAction){ case "build": - if ($sParam4){ - $aResult=$oProject->setBranchname($sParam4 . ($sParam5 ? '/'.$sParam5 : '')); + if ($sBranch){ + $aResult=$oProject->setBranchname($sBranch); } $sBranchname=$oProject->getBranchname(); $aRepodata = $oProject->getRemoteBranches(true); diff --git a/public_html/deployment/classes/vcs.git.class.php b/public_html/deployment/classes/vcs.git.class.php index 5032ae7784c52df34f50fcb5b5d36baf401b7eba..d8d50f9872181d3faea4f85c93711d97f332ca85 100644 --- a/public_html/deployment/classes/vcs.git.class.php +++ b/public_html/deployment/classes/vcs.git.class.php @@ -200,6 +200,7 @@ class vcs implements iVcs { /** * helper: cache hash with all branches + * It saves 1.5 sec for reading 300 branches * @return boolean */ private function _cacheRemoteBranches() { @@ -277,14 +278,14 @@ class vcs implements iVcs { $sBranchKey = $sName; $this->log(__FUNCTION__ . ' $sBranchKey = '.$sBranchKey); - $sMessage = $this->getCommitmessageByBranch($sName, $sRevision); + // $sMessage = $this->getCommitmessageByBranch($sName, $sRevision); $aReturn[$sBranchKey] = array( // 'debug'=> $aTmp, 'revision' => $sRevision, 'name' => $sName, 'label' => $sType . ': ' . $sBranch, 'type' => $sType, - 'message' => $sMessage + // 'message' => $sMessage ); } } diff --git a/shellscripts/api-imlciserver.sh b/shellscripts/api-imlciserver.sh index b61fe3f5c08b3aebb41a9e0b3d8726dc78d43ebb..d92f202be98c9e8a5a9b2c5020e13a874c410a07 100644 --- a/shellscripts/api-imlciserver.sh +++ b/shellscripts/api-imlciserver.sh @@ -4,8 +4,9 @@ # API CLIENT :: API REQUEST TO IML CI SERVER # # ---------------------------------------------------------------------- -# 2020-07-23 v1.0 <axel.hahn@iml.unibe.ch> first lines +# 2020-07-23 v1.0 <axel.hahn@iml.unibe.ch> first lines # 2020-07-29 v1.1 <axel.hahn@iml.unibe.ch> check "/" in branch; check http status 200 +# 2021-03-29 v1.2 <axel.hahn@iml.unibe.ch> support slashes in branch names # ====================================================================== # ---------------------------------------------------------------------- @@ -146,7 +147,8 @@ echo "IMLCI_PROJECT = $IMLCI_PROJECT" echo "IMLCI_API_SECRET = $IMLCI_API_SECRET" echo -echo $branch | grep '/.*/.*' >/dev/null && ( echo "WARNING: Do NOT use a branch containing a slash [/] in the name"; echo ) +# task-4364: slashes are supported now +# echo $branch | grep '/.*/.*' >/dev/null && ( echo "WARNING: Do NOT use a branch containing a slash [/] in the name"; echo ) echo ACTION: $apiAction