diff --git a/config/lang/de.json b/config/lang/de.json index 4140164fcad611232d6958cdc447317f794ee4f1..aad1ebb87d116d3ff3e5fb6abdb89c1afc143ccd 100644 --- a/config/lang/de.json +++ b/config/lang/de.json @@ -199,6 +199,7 @@ "archive": "Archiv", "branch": "Branch/ Tag", "branch-select": "Vorhandene Branches und Tags", + "branch-switch": "Switche Branch/ Tag ... Moment ...", "build": "Build", "build-hint": "neues Paket erstellen und in Phase [%s] stellen.", "build-from": "Build vom", diff --git a/config/lang/en.json b/config/lang/en.json index 7421406a17c0c960a01d73db28b3aa740dddbc6c..8248e664ec1fdc67296b7fe72ed0440baad916d8 100644 --- a/config/lang/en.json +++ b/config/lang/en.json @@ -201,6 +201,7 @@ "archive": "Archive", "branch": "Branch/ tag", "branch-select": "Existing branches and tags", + "branch-switch": "Switching branch/ tag ... please wait ...", "build": "Build", "build-hint": "Create new package and rollout to first active phase [%s].", "build-from": "Build date", diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index f098cd5936e7c571a797cdbf8132e033fc3901ef..194b712739369216835c88fb184c8fb74418ecfa 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -929,6 +929,7 @@ class project { $aForms['frmSelectBranch']['form']['submitBranch'] = array( 'type' => 'submit', 'name' => 'btnsave', + 'onclick' => 'showModalMessage(\''.t('branch-switch').'\'); ', 'label' => t("change"), 'value' => '<i class="icon-ok"></i> ' . t("change"), ); diff --git a/public_html/deployment/classes/projectlist.class.php b/public_html/deployment/classes/projectlist.class.php index f72b9500eeb525a79cb63ec582a2c8c437066b60..6c9dc1c46b163dc83cb48a2bf6f8fab53abf57c8 100644 --- a/public_html/deployment/classes/projectlist.class.php +++ b/public_html/deployment/classes/projectlist.class.php @@ -111,6 +111,7 @@ class projectlist extends base{ . '<td class="prj">' . '<a href="" onclick="setProjectFilter(\'' . $sPrj . '\'); return false;" ' . 'style="float: right;" ' + . 'class="btn" ' . 'title="' . t("overview-filter-hint") . '"><i class="icon-filter"></i> ' . t("overview-filter") . '</a>' . '</td>' . '<td class="prj">'; diff --git a/public_html/deployment/classes/vcs.git.class.php b/public_html/deployment/classes/vcs.git.class.php index 0f8bce58760f494ae3596c9aef3536941614c4f6..9b421b81febd972ee8225ac4eb5fb2831aec8fb3 100644 --- a/public_html/deployment/classes/vcs.git.class.php +++ b/public_html/deployment/classes/vcs.git.class.php @@ -140,48 +140,84 @@ class vcs implements iVcs { return $this->_aCfg["type"]; } + + private function _getNameOfCacheModule(){ + $sReturn="git".$this->getUrl(); + $sReturn=preg_replace('/([^0-9a-z])/i', "", $sReturn); + // echo "DEBUG: getNameOfCacheModule $sReturn<br>"; + return $sReturn; + } + /** + * cleanup cache data for this project (revisions, list of branches+tags) + * @return bool + */ + private function _cleanupCache(){ + require_once 'cache.class.php'; + $oCache=new AhCache($this->_getNameOfCacheModule()); + return $oCache->cleanup(); + } + + + /** * read remote repository and get an array with names and revisions of * all branches and tags * pre branch you get an array element with the keys revision, name, type + * @param bool $bForceNoCache flag to overrde cache * @return array */ - private function _fetchRemoteBranches() { + private function _fetchRemoteBranches($bForceNoCache=false) { $aReturn = array(); + $sGitCmd = 'export GIT_SSH="' . $this->_sWrapper . '" ; export PKEY="' . $this->_sKeyfile . '" ; '; if (!$this->getUrl()) { return false; } - if (!file_exists($this->_sTempDir . ".git")) { - $sGitCmd.='mkdir "' . $this->_sTempDir . '" && cd "' . $this->_sTempDir . '" && '; - $sGitCmd.='git init >/dev/null && '; - $sGitCmd.='git remote add origin "' . $this->getUrl() . '" 2>&1 && '; - } else { - $sGitCmd.='cd "' . $this->_sTempDir . '" 2>&1 && '; - } - // $sGitCmd.='git branch -r ; '; - $sGitCmd.='git ls-remote --heads origin 2>&1 ; git ls-remote --tags origin 2>&1 '; - exec($sGitCmd, $aOutput, $iRc); - if ($iRc == 0) { - foreach ($aOutput as $sBranch) { - $aTmp = explode("\t", $sBranch); - - $aBranch = explode("/", $aTmp[1]); - - $sBranch = array_pop($aBranch); - $sType = array_pop($aBranch); - if ($sType == "heads") { - $sBranch = "origin/" . $sBranch; + $iTtl=300; // cache for 5 min + require_once 'cache.class.php'; + $oCache=new AhCache($this->_getNameOfCacheModule(), "RemoteBranches"); + if ($oCache->isExpired() || $bForceNoCache || true){ + if (!file_exists($this->_sTempDir . ".git")) { + $sGitCmd.='mkdir "' . $this->_sTempDir . '" && cd "' . $this->_sTempDir . '" && '; + $sGitCmd.='git init >/dev/null && '; + $sGitCmd.='git remote add origin "' . $this->getUrl() . '" 2>&1 && '; + } else { + $sGitCmd.='cd "' . $this->_sTempDir . '" 2>&1 && '; + } + // $sGitCmd.='git branch -r ; '; + $sGitCmd.='git ls-remote --heads origin 2>&1 ; git ls-remote --tags origin 2>&1 '; + exec($sGitCmd, $aOutput, $iRc); + if ($iRc == 0) { + foreach ($aOutput as $sBranch) { + $aTmp = explode("\t", $sBranch); + + $aBranch = explode("/", $aTmp[1]); + + $sBranch = array_pop($aBranch); + + // skip dereferences + // http://stackoverflow.com/questions/15472107/when-listing-git-ls-remote-why-theres-after-the-tag-name + if (!preg_match('/\^\{\}$/', $sBranch)){ + $sType = array_pop($aBranch); + if ($sType == "heads") { + $sBranch = "origin/" . $sBranch; + } + + $aReturn[] = array( + // 'debug'=> $aTmp, + 'revision' => $aTmp[0], + 'name' => $sBranch, + 'label' => $sType . ': ' . $sBranch, + 'type' => $sType + ); + } } - - $aReturn[] = array( - // 'debug'=> $aTmp, - 'revision' => $aTmp[0], - 'name' => $sBranch, - 'label' => $sType . ': ' . $sBranch, - 'type' => $sType - ); + // echo "DEBUG: refresh cache for branches and tags <br>"; + $oCache->write($aReturn, $iTtl); } + } else { + // echo "DEBUG: using cache for branches and tags <br>"; + $aReturn=$oCache->read(); } $this->_aRemoteBranches = $aReturn; return $aReturn; @@ -230,46 +266,60 @@ class vcs implements iVcs { if (!$this->getUrl()) { return false; } - - if ($sWorkDir) { - $sGitCmd.='cd "' . $sWorkDir . '" && '; - } else { - if (!file_exists($this->_sTempDir . ".git")) { - $sGitCmd.='mkdir "' . $this->_sTempDir . '" && cd "' . $this->_sTempDir . '" && '; - $sGitCmd.='git init >/dev/null 2>&1 && '; - $sGitCmd.='git remote add origin "' . $this->getUrl() . '" 2>&1 && '; + + $iTtl=300; // cache for 5 min + require_once 'cache.class.php'; + $oCache=new AhCache($this->_getNameOfCacheModule(), "Revision-".$this->_sCurrentBranch ."-". $sWorkDir); + + if ($oCache->isExpired()){ + + if ($sWorkDir) { + $sGitCmd.='cd "' . $sWorkDir . '" && '; } else { - $sGitCmd.='cd "' . $this->_sTempDir . '" && '; + if (!file_exists($this->_sTempDir . ".git")) { + $sGitCmd.='mkdir "' . $this->_sTempDir . '" && cd "' . $this->_sTempDir . '" && '; + $sGitCmd.='git init >/dev/null 2>&1 && '; + $sGitCmd.='git remote add origin "' . $this->getUrl() . '" 2>&1 && '; + } else { + $sGitCmd.='cd "' . $this->_sTempDir . '" && '; + } + + // TODO: git 1.9 does needs only the line with --tags + $sGitCmd.=' ( ' + . 'git fetch --update-head-ok --tags --depth 1 2>&1 ; ' + . 'git fetch --update-head-ok --depth 1 2>&1 ' + . ') && '; } - - // TODO: git 1.9 does needs only the line with --tags - $sGitCmd.=' ( ' - . 'git fetch --update-head-ok --tags --depth 1 2>&1 ; ' - . 'git fetch --update-head-ok --depth 1 2>&1 ' - . ') && '; - } - $sGitCmd.='git log -1 "' . $this->_sCurrentBranch . '" 2>&1 ; '; - $sLoginfo = shell_exec($sGitCmd); + $sGitCmd.='git log -1 "' . $this->_sCurrentBranch . '" 2>&1 ; '; + $sLoginfo = shell_exec($sGitCmd); - $sRevision = false; - if (preg_match('#commit\ (.*)#', $sLoginfo, $aRev)) { - $sRevision = $aRev[1]; - } + $sRevision = false; + if (preg_match('#commit\ (.*)#', $sLoginfo, $aRev)) { + $sRevision = $aRev[1]; + } + - if ($sRevision) { - $aReturn = array( - "branch" => $this->_sCurrentBranch, - "revision" => $sRevision, - "message" => $sLoginfo - ); - } else { - if (!$sLoginfo) { - $sLoginfo = $sGitCmd; + if ($sRevision) { + $aReturn = array( + "branch" => $this->_sCurrentBranch, + "revision" => $sRevision, + "message" => $sLoginfo + ); + // echo "DEBUG: refresh cache for git revision<br>"; + $oCache->write($aReturn, $iTtl); + } else { + if (!$sLoginfo) { + $sLoginfo = $sGitCmd; + } + // echo "DEBUG: error on reading git revision<br>"; + $aReturn = array( + "error" => '<pre>' . $sLoginfo . '<hr>' . $sGitCmd . '</pre>' + ); } - $aReturn = array( - "error" => '<pre>' . $sLoginfo . '<hr>' . $sGitCmd . '</pre>' - ); + } else { + // echo "DEBUG: use cache for git revision<br>"; + $aReturn=$oCache->read(); } return $aReturn; } diff --git a/public_html/deployment/js/functions.js b/public_html/deployment/js/functions.js index dc54f043fc0144355d2357c66ad494ddfa1b87de..488d4e4ec83647d77e2704581b44485171a9cb0e 100644 --- a/public_html/deployment/js/functions.js +++ b/public_html/deployment/js/functions.js @@ -22,6 +22,24 @@ function initSoftscroll(){ }); } +function showModalMessage(sMessage){ + $('#divmodalmessage').html(sMessage); + $('#divmodal').show(); +} +function hideModalMessage(){ + $('#divmodal').hide(); +} + +// ---------------------------------------------------------------------- +// general init in each page +// ---------------------------------------------------------------------- + +$(document).ready(function() { + initSoftscroll(); + // $(".optionName").popover({trigger: "hover"}); + // $("#content").hide().fadeIn(300); +}); + // ---------------------------------------------------------------------- // action log @@ -94,7 +112,7 @@ function updateActionlog(){ } /** -* filter table with action logs by filtertext +* filter table with action logs by filtertext (input field) */ function filterLogTable(){ var sSearch=$("#efilterlogs").val(); @@ -109,13 +127,3 @@ function filterLogTable(){ return false; } - -// ---------------------------------------------------------------------- -// general init in each page -// ---------------------------------------------------------------------- - -$(document).ready(function() { - initSoftscroll(); - // $(".optionName").popover({trigger: "hover"}); - // $("#content").hide().fadeIn(300); -}); \ No newline at end of file diff --git a/public_html/deployment/main.css b/public_html/deployment/main.css index 8e63a3a28e26bca68a007bab889ebd9c65f5c0dd..39ced0129a7da960d5a9145b649ceb60a7e2e263 100644 --- a/public_html/deployment/main.css +++ b/public_html/deployment/main.css @@ -57,6 +57,16 @@ div#navbuttom{ margin-top: 4em; padding: 1em 0; border-top: 2px dotted #ccc;} +#divmodal{ + position: fixed; height: 100%; width: 100%; top:0; left:0; + background: #ccc; background: rgba(0,0,0,0.05); + display: none; +} +#divmodalmessage{ + margin: 20% auto; width: 50%; background: #fff; box-shadow: 0 0 3em #000; + padding: 2em; +} + h1{font-size: 250%; margin: 0;} h2{}