From c4149a497b2973166395a194194cba96e53d8cdd Mon Sep 17 00:00:00 2001
From: Axel Hahn <axel.hahn@iml.unibe.ch>
Date: Wed, 22 Apr 2015 16:50:57 +0200
Subject: [PATCH] - fix: checkout tags with git version 1.7

---
 public_html/deployment/classes/vcs.git.class.php | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/public_html/deployment/classes/vcs.git.class.php b/public_html/deployment/classes/vcs.git.class.php
index af89c12a..bb3c67e2 100644
--- a/public_html/deployment/classes/vcs.git.class.php
+++ b/public_html/deployment/classes/vcs.git.class.php
@@ -444,12 +444,20 @@ class vcs implements iVcs {
         $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 . '" ; ';
-        $sGitCmd .= 'git clone --depth 1 --recursive --branch "' . $sBranchname . '" "' . $this->getUrl() . '" "' . $sWorkDir . '" 2>&1; ';
+        
+        // this does not checkout tags in git v1.7 - only branches:
+        // $sGitCmd .= 'echo git clone --depth 1 --recursive --branch "' . $sBranchname . '" "' . $this->getUrl() . '" "' . $sWorkDir . '" ; ';
+        // $sGitCmd .= '     git clone --depth 1 --recursive --branch "' . $sBranchname . '" "' . $this->getUrl() . '" "' . $sWorkDir . '" 2>&1; ';
+        // 
+        $sGitCmd .= 'echo git clone "' . $this->getUrl() . '" "'.$sWorkDir.'" 2>&1 \&\& cd  "'.$sWorkDir.'" \&\& git checkout "' . $sBranchname . '" ; ';
+        $sGitCmd .= '     git clone "' . $this->getUrl() . '" "'.$sWorkDir.'" 2>&1 && cd  "'.$sWorkDir.'" && git checkout 2>&1 ';
         $this->log(__FUNCTION__." start command $sGitCmd");
-        $sReturn = shell_exec($sGitCmd);
+        // $sReturn = shell_exec($sGitCmd);
+        exec($sGitCmd, $sReturn, $iRc);
+        
+        echo print_r($sReturn, 1) . "<br>rc=$rc<br>";
         $this->log(__FUNCTION__." end command $sGitCmd");
-        return $sReturn;
+        return implode("\n", $sReturn). "\nrc=$iRc";
     }
 
     /**
-- 
GitLab