Skip to content
Snippets Groups Projects
Commit 0fd07cd5 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '5708-override-cache-of-branches' into 'master'

5708 override cache of branches

See merge request !34
parents f055b9f8 0854bd68
No related branches found
No related tags found
1 merge request!345708 override cache of branches
Pipeline #870 passed
...@@ -1198,18 +1198,18 @@ class project extends base { ...@@ -1198,18 +1198,18 @@ class project extends base {
/** /**
* get list of remote branches and tags * get list of remote branches and tags
* @param type $getRemoteBranches * @param bool $bIgnoreCache flag to ignore exiting cached data
* @return string|boolean * @return string|boolean
*/ */
public function getRemoteBranches($bForceNoCache=false) { public function getRemoteBranches($bIgnoreCache=false) {
$this->log(__FUNCTION__ . "($bForceNoCache) start"); $this->log(__FUNCTION__ . "($bIgnoreCache) start");
$this->_initVcs(); $this->_initVcs();
if ($this->_oVcs) { if ($this->_oVcs) {
if (!method_exists($this->_oVcs, "getRemoteBranches")) { if (!method_exists($this->_oVcs, "getRemoteBranches")) {
// the version control class does not have this method // the version control class does not have this method
return ''; return '';
} }
return $this->_oVcs->getRemoteBranches($bForceNoCache); return $this->_oVcs->getRemoteBranches($bIgnoreCache);
} }
return false; return false;
} }
...@@ -1218,9 +1218,11 @@ class project extends base { ...@@ -1218,9 +1218,11 @@ class project extends base {
} }
* get html form with selectr for remote branches * get html form with selectr for remote branches
* @param string $sActiveBranchname force active branch name * @param string $sActiveBranchname force active branch name
* @param bool $bIgnoreCache flag to ignore exiting cached data
* @return string * @return string
*/ */
public function renderSelectRemoteBranches($sActiveBranchname = false, $bForceNoCache=false) { public function renderSelectRemoteBranches($sActiveBranchname = false, $bIgnoreCache=false) {
$this->log(__FUNCTION__."(sActiveBranchname = $sActiveBranchname, bIgnoreCache = ".($bIgnoreCache ? 'true' : 'false').") start");
$aReturn = array(); $aReturn = array();
$aRadios = array(); $aRadios = array();
$bFoundActive = false; $bFoundActive = false;
...@@ -1237,7 +1239,7 @@ class project extends base { ...@@ -1237,7 +1239,7 @@ class project extends base {
// the version control class does not have this method // the version control class does not have this method
return ''; return '';
} }
foreach ($this->_oVcs->getRemoteBranches($bForceNoCache) as $aBranch) { foreach ($this->_oVcs->getRemoteBranches($bIgnoreCache) as $aBranch) {
$sBranch = $aBranch['name']; $sBranch = $aBranch['name'];
$aRadios[$sBranch] = array( $aRadios[$sBranch] = array(
'value' => $sBranch, 'value' => $sBranch,
......
...@@ -217,11 +217,11 @@ class vcs implements iVcs { ...@@ -217,11 +217,11 @@ class vcs implements iVcs {
* read remote repository and get an array with names and revisions of * read remote repository and get an array with names and revisions of
* all branches and tags * all branches and tags
* pre branch you get an array element with the keys revision, name, type * pre branch you get an array element with the keys revision, name, type
* @param bool $bForceNoCache flag to overrde cache * @param bool $bIgnoreCache flag to overrde cache
* @return array * @return array
*/ */
private function _fetchRemoteBranches($bForceNoCache = false) { private function _fetchRemoteBranches($bIgnoreCache = false) {
$this->log(__FUNCTION__."(bForceNoCache = ".($bForceNoCache ? 'true' : 'false').") start"); $this->log(__FUNCTION__."(bIgnoreCache = ".($bIgnoreCache ? 'true' : 'false').") start");
$aReturn = array(); $aReturn = array();
if (!$this->getUrl()) { if (!$this->getUrl()) {
...@@ -233,7 +233,7 @@ class vcs implements iVcs { ...@@ -233,7 +233,7 @@ class vcs implements iVcs {
$iRc=false; $iRc=false;
// list of cached branch keys // list of cached branch keys
if ($oCache->isExpired() || $bForceNoCache) { if ($oCache->isExpired() || $bIgnoreCache) {
$sWorkdir = dirname($this->_sTempDir) . '/fetchRemoteBranches/'; $sWorkdir = dirname($this->_sTempDir) . '/fetchRemoteBranches/';
$this->log(__FUNCTION__." - sWorkdir = $sWorkdir"); $this->log(__FUNCTION__." - sWorkdir = $sWorkdir");
$sGitCmd = 'export GIT_SSH="' . $this->_sWrapper . '" ; export PKEY="' . $this->_sKeyfile . '" ; '; $sGitCmd = 'export GIT_SSH="' . $this->_sWrapper . '" ; export PKEY="' . $this->_sKeyfile . '" ; ';
...@@ -253,7 +253,8 @@ class vcs implements iVcs { ...@@ -253,7 +253,8 @@ class vcs implements iVcs {
// use cache that getCommitmessageByBranch can access it // use cache that getCommitmessageByBranch can access it
$this->_aRemoteBranches = $oCache->read(); $this->_aRemoteBranches = $oCache->read();
$this->log(__FUNCTION__ . ' data from cache: <pre>'.print_r($this->_aRemoteBranches, 1).'</pre>'); $this->log(__FUNCTION__ . ' start reading all branches');
// $this->log(__FUNCTION__ . ' data from cache: <pre>'.print_r($this->_aRemoteBranches, 1).'</pre>');
/** /**
* $aOutput = Array * $aOutput = Array
* ( * (
...@@ -264,7 +265,7 @@ class vcs implements iVcs { ...@@ -264,7 +265,7 @@ class vcs implements iVcs {
*/ */
foreach ($aOutput as $sBranchLine) { foreach ($aOutput as $sBranchLine) {
$this->log(__FUNCTION__ . ' loop over output of git ls-remote <pre>'.print_r($sBranchLine, 1).'</pre>'); // $this->log(__FUNCTION__ . ' loop over output of git ls-remote <pre>'.print_r($sBranchLine, 1).'</pre>');
$aTmp = explode("\t", $sBranchLine); $aTmp = explode("\t", $sBranchLine);
$sBranchPath = preg_replace('#^refs/#', '', $aTmp[1]); $sBranchPath = preg_replace('#^refs/#', '', $aTmp[1]);
...@@ -278,7 +279,7 @@ class vcs implements iVcs { ...@@ -278,7 +279,7 @@ class vcs implements iVcs {
$sName = ($sType == "heads") ? "origin/" . $sBranch : $sBranch; $sName = ($sType == "heads") ? "origin/" . $sBranch : $sBranch;
$sBranchKey = $sName; $sBranchKey = $sName;
$this->log(__FUNCTION__ . ' $sBranchKey = '.$sBranchKey); // $this->log(__FUNCTION__ . ' $sBranchKey = '.$sBranchKey);
// $sMessage = $this->getCommitmessageByBranch($sName, $sRevision); // $sMessage = $this->getCommitmessageByBranch($sName, $sRevision);
$aReturn[$sBranchKey] = array( $aReturn[$sBranchKey] = array(
...@@ -292,6 +293,7 @@ class vcs implements iVcs { ...@@ -292,6 +293,7 @@ class vcs implements iVcs {
} }
} }
$this->_aRemoteBranches = $aReturn; $this->_aRemoteBranches = $aReturn;
$this->log(__FUNCTION__ . ' '.count($aReturn).' branches: <pre>'.print_r($this->_aRemoteBranches, 1).'</pre>');
$this->_cacheRemoteBranches(); $this->_cacheRemoteBranches();
} }
} else { } else {
...@@ -302,13 +304,13 @@ class vcs implements iVcs { ...@@ -302,13 +304,13 @@ class vcs implements iVcs {
/** /**
* get a flat array with names of all remote branches * get a flat array with names of all remote branches
* @param bool $bForceNoCache flag: ignore caching; default: use cache * @param bool $bIgnoreCache flag: ignore caching; default: use cache
* @return array * @return array
*/ */
public function getRemoteBranches($bForceNoCache=false) { public function getRemoteBranches($bIgnoreCache=false) {
$this->log(__FUNCTION__."($bForceNoCache) start"); $this->log(__FUNCTION__."($bIgnoreCache) start");
if (!$this->_aRemoteBranches) { if (!$this->_aRemoteBranches || $bIgnoreCache) {
$this->_fetchRemoteBranches($bForceNoCache); $this->_fetchRemoteBranches($bIgnoreCache);
} }
return $this->_aRemoteBranches; return $this->_aRemoteBranches;
} }
......
...@@ -36,7 +36,9 @@ if (!array_key_exists("confirm", $aParams)) { ...@@ -36,7 +36,9 @@ if (!array_key_exists("confirm", $aParams)) {
// ------------------------------------------------------------ // ------------------------------------------------------------
$sNext = $oPrj->getNextPhase(); $sNext = $oPrj->getNextPhase();
$aPhaseData2 = $oPrj->getPhaseInfos($sNext); $aPhaseData2 = $oPrj->getPhaseInfos($sNext);
$bForceNoCache = isset($aParams['reloadBranches']) ? $aParams['reloadBranches'] : false; $bIgnoreCache = isset($aParams['reloadBranches']) ? $aParams['reloadBranches'] : false;
// $sOut.='<p>Re-Read Branches (ignore caching) - '.($bIgnoreCache ? "JA" : "mein" ).'</p>';
$sOut.='<p>' . sprintf(t("page-build-info"), $sNext, $sNext) . '</p>'; $sOut.='<p>' . sprintf(t("page-build-info"), $sNext, $sNext) . '</p>';
...@@ -67,7 +69,7 @@ if (!array_key_exists("confirm", $aParams)) { ...@@ -67,7 +69,7 @@ if (!array_key_exists("confirm", $aParams)) {
<tbody> <tbody>
<tr> <tr>
<td class=""> <td class="">
' . $oPrj->renderSelectRemoteBranches(false, $bForceNoCache) . ' ' . $oPrj->renderSelectRemoteBranches(false, $bIgnoreCache) . '
<form action="?" method="post" enctype="multipart/form-data"> <form action="?" method="post" enctype="multipart/form-data">
<input type="hidden" name="reloadBranches" value="1"> <input type="hidden" name="reloadBranches" value="1">
<input type="hidden" name="branchname" value="' . $sBranchname . '"> <input type="hidden" name="branchname" value="' . $sBranchname . '">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment