From 52e9055a40ed7c7af3b558fe57f42140c73ec89c Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Mon, 6 Jan 2025 16:30:57 +0100
Subject: [PATCH] build(): add check if vcs was read correctly

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

diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php
index 3f2aa08f..3b7e633a 100644
--- a/public_html/deployment/classes/project.class.php
+++ b/public_html/deployment/classes/project.class.php
@@ -1802,13 +1802,21 @@ class project extends base
             return $this->_oHtml->getBox("error", "" . $sReturn);
         }
 
-
+        // read commit message and fetch meta data
         $aRepodata = $this->getRepoRevision();
-        $sRevisionShort = substr($aRepodata['revision'], 0, 8);
-
         $sReturn .= $this->_oHtml->getBox("info", t('commitmessage') . '<pre>' . htmlentities($aRepodata['message']) . '</pre>');
-        $sReturn .= $this->_execAndSend("ls -lisa $sTempBuildDir");
 
+        // #7706 check if a branch was detected
+        if(!isset($aRepodata['branch']) || !$aRepodata['branch']){
+            $sError = t('class-project-error-unable-to-read-vcs-metadata');
+            $this->_logaction($sError, __FUNCTION__, "error");
+            $this->_TempFill($sError . $sReturn, $aActionList);
+            $this->_TempDelete($sTempBuildDir);
+            return $this->_oHtml->getBox("error", $sError . $sReturn);
+        }
+        $sRevisionShort = substr($aRepodata['revision'], 0, 8);
+        
+        $sReturn .= $this->_execAndSend("ls -lisa $sTempBuildDir");
         if (!$this->_iRcAll == 0) {
             $sError = sprintf(t('class-project-error-command-failed'), $sTempBuildDir);
             $this->_logaction($sError, __FUNCTION__, "error");
-- 
GitLab