Skip to content
Snippets Groups Projects
Commit 376c8168 authored by Axel Hahn's avatar Axel Hahn
Browse files

- added: deploy tags

- changed: slect branch is a dropdown (instead of radio list)
- fixed: show stderr on commands
parent a286111f
Branches
No related tags found
No related merge requests found
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
......@@ -212,7 +212,7 @@ class formgen {
$s = preg_replace('/\W/iu', '', $sId . $idOption);
$sOptionId = preg_replace('/[äöüß]/i', '', $s);
$sFormElement.=' <option value="' . $idOption . '" ';
$sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes"), $aOptionData);
$sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,selected"), $aOptionData);
$sFormElement.='>' . $aOptionData["label"] . '</option>' . "\n";
}
$sFormElement.="</select>\n";
......
......@@ -169,6 +169,8 @@ class project {
}
// ob_end_flush();
// stderr ausgeben
$sCommand.=' 2>&1';
$sReturn.="[" . date("H:i:s d.m.Y") . "] ";
$sReturn.=$bUseHtml ? "<strong>$sCommand</strong>" : "$sCommand";
$sReturn.=$bUseHtml ? "<br>" : "\n";
......@@ -848,9 +850,11 @@ class project {
// the version control class does not have this method
return '';
}
foreach ($this->_oVcs->getRemoteBranches() as $sBranch) {
foreach ($this->_oVcs->getRemoteBranches() as $aBranch) {
$sBranch=$aBranch['name'];
$aRadios[$sBranch] = array(
'label' => $sBranch,
'value' => $sBranch,
'label' => $aBranch['label'],
);
// if no param was given the first branch will be marked
if (!$sActiveBranchname) {
......@@ -858,7 +862,8 @@ class project {
}
if ($sBranch == $sActiveBranchname) {
$bFoundActive = true;
$aRadios[$sBranch]['checked'] = 'checked';
// $aRadios[$sBranch]['checked'] = 'checked';
$aRadios[$sBranch]['selected'] = 'selected';
} else {
$aRadios[$sBranch]['onclick'] = 'document.getElementById(\'submitBranch\').click()';
}
......@@ -879,7 +884,8 @@ class project {
'validate' => array(),
'form' => array(
'branchname' => array(
'type' => 'radio',
'inline' => true,
'type' => 'select',
'name' => 'branchname',
'label' => '<strong>' . t('branch-select') . '</strong>',
'validate' => 'isastring',
......
......@@ -98,6 +98,7 @@ class vcs implements iVcs {
public function setCurrentBranch($sBranchname) {
return $this->_sCurrentBranch = $sBranchname;
}
/**
* helper: dump values
* @return boolean
......@@ -140,7 +141,9 @@ class vcs implements iVcs {
}
/**
* read remote repository and get a flat array with names of all branches
* 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
* @return array
*/
private function _fetchRemoteBranches() {
......@@ -156,12 +159,28 @@ class vcs implements iVcs {
} else {
$sGitCmd.='cd "' . $this->_sTempDir . '" && ';
}
$sGitCmd.='git branch -r ; ';
// $sGitCmd.='git branch -r ; ';
$sGitCmd.='git ls-remote --heads origin; git ls-remote --tags origin';
exec($sGitCmd, $aOutput, $iRc);
if ($iRc == 0) {
foreach ($aOutput as $sBranch) {
// $aReturn[] = str_replace("origin/", "", trim($sBranch));
$aReturn[] = trim($sBranch);
$aTmp = explode("\t", $sBranch);
$aBranch = explode("/", $aTmp[1]);
$sBranch = array_pop($aBranch);
$sType = array_pop($aBranch);
if ($sType == "heads") {
$sBranch = "origin/" . $sBranch;
}
$aReturn[] = array(
// 'debug'=> $aTmp,
'revision' => $aTmp[0],
'name' => $sBranch,
'label' => $sType . ': ' . $sBranch,
'type' => $sType
);
}
}
$this->_aRemoteBranches = $aReturn;
......@@ -222,7 +241,7 @@ class vcs implements iVcs {
} else {
$sGitCmd.='cd "' . $this->_sTempDir . '" && ';
}
$sGitCmd.='git fetch --update-head-ok --depth 1 2>&1 && ';
$sGitCmd.='git fetch --update-head-ok --tags --depth 1 2>&1 && ';
}
$sGitCmd.='git log -1 "' . $this->_sCurrentBranch . '" ; ';
......@@ -261,8 +280,7 @@ class vcs implements iVcs {
if (!$this->getUrl()) {
return false;
}
$sBranchname=$this->_sCurrentBranch;
$sBranchname=str_replace("origin/", "", $sBranchname);
$sBranchname = str_replace("origin/", "", $this->_sCurrentBranch);
$sGitCmd = 'export GIT_SSH="' . $this->_sWrapper . '" ; export PKEY="' . $this->_sKeyfile . '" ; ';
$sGitCmd .= 'echo git clone --depth 1 --recursive --branch "' . $sBranchname . '" "' . $this->getUrl() . '" "' . $sWorkDir . '" ; ';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment