Skip to content
Snippets Groups Projects
Commit 91db7a74 authored by hahn's avatar hahn
Browse files

task#4364 - support branches with slashes

parent 0375b818
No related branches found
No related tags found
1 merge request!3Task4364 branchname chars; do not fetch all commit messages
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
* *
* ---------------------------------------------------------------------- * ----------------------------------------------------------------------
* 2020-06-16 v0.9 <axel.hahn@iml.unibe.ch> * 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 @@ ...@@ -132,11 +133,11 @@
$aUriSplit= explode('/', preg_replace('/\?.*$/', '', $_SERVER["REQUEST_URI"])); $aUriSplit= explode('/', preg_replace('/\?.*$/', '', $_SERVER["REQUEST_URI"]));
array_shift($aUriSplit); array_shift($aUriSplit);
array_shift($aUriSplit); array_shift($aUriSplit);
_wd('<pre>$aUriSplit: '.print_r($aUriSplit, 1).'</pre>'); _wd('<pre>$aUriSplit: '.print_r($aUriSplit, 1).'</pre>');
/* /*
/api/v1/projects/ci/build?auth=123 /api/v1/projects/ci/build/...
$aUriSplit: Array $aUriSplit: Array
( (
[0] => v1 [0] => v1
...@@ -173,11 +174,14 @@ ...@@ -173,11 +174,14 @@
$sPrjId = isset($aUriSplit[2]) ? $aUriSplit[2] : false; $sPrjId = isset($aUriSplit[2]) ? $aUriSplit[2] : false;
$sPrjAction = isset($aUriSplit[3]) ? $aUriSplit[3] : false; $sPrjAction = isset($aUriSplit[3]) ? $aUriSplit[3] : false;
$sParam4 = isset($aUriSplit[4]) ? $aUriSplit[4] : false; $sBranch = implode('/', array_slice($aUriSplit, 4));
$sParam5 = isset($aUriSplit[5]) ? $aUriSplit[5] : false;
// $sParam4 = isset($aUriSplit[4]) ? $aUriSplit[4] : false;
// $sParam5 = isset($aUriSplit[5]) ? $aUriSplit[5] : false;
$sMethod = $_SERVER['REQUEST_METHOD']; $sMethod = $_SERVER['REQUEST_METHOD'];
_wd('$sPrjId = '.$sPrjId); _wd('$sPrjId = '.$sPrjId);
_wd('$sPrjAction = '.$sPrjAction); _wd('$sPrjAction = '.$sPrjAction);
_wd('$sBranch = ' . $sBranch);
$oCLog = new logger(); $oCLog = new logger();
// try to init the given project // try to init the given project
...@@ -208,8 +212,8 @@ ...@@ -208,8 +212,8 @@
switch($sPrjAction){ switch($sPrjAction){
case "build": case "build":
if ($sParam4){ if ($sBranch){
$aResult=$oProject->setBranchname($sParam4 . ($sParam5 ? '/'.$sParam5 : '')); $aResult=$oProject->setBranchname($sBranch);
} }
$sBranchname=$oProject->getBranchname(); $sBranchname=$oProject->getBranchname();
$aRepodata = $oProject->getRemoteBranches(true); $aRepodata = $oProject->getRemoteBranches(true);
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
# API CLIENT :: API REQUEST TO IML CI SERVER # 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 # 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" ...@@ -146,7 +147,8 @@ echo "IMLCI_PROJECT = $IMLCI_PROJECT"
echo "IMLCI_API_SECRET = $IMLCI_API_SECRET" echo "IMLCI_API_SECRET = $IMLCI_API_SECRET"
echo 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 echo ACTION: $apiAction
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment