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 1/3] 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


From 0faa359578c6a7d222bf62bbebf01edc79563919 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Mon, 6 Jan 2025 16:31:08 +0100
Subject: [PATCH 2/3] add lang textss

---
 config/lang/de-de.json | 1 +
 config/lang/en-en.json | 1 +
 2 files changed, 2 insertions(+)

diff --git a/config/lang/de-de.json b/config/lang/de-de.json
index 87765b90..89dfda15 100644
--- a/config/lang/de-de.json
+++ b/config/lang/de-de.json
@@ -79,6 +79,7 @@
     "class-project-error-archivedir-empty": "FEHLER::KONFIGURATION: Das Archiv-Verzeichnis ($aConfig[&quot;archiveDir&quot;]) ist leer; es muss auf ein Verzeichnis zeigen.",
     "class-project-error-build-dir-was-not-created": "Das Verzeichnis %s wurde nicht angelegt.",
     "class-project-error-build-type-not-supported": "Repository Typ %s wird nicht unterst&uuml;tzt.",
+    "class-project-error-unable-to-read-vcs-metadata": "Die VCS Metadaten zum Branch konnten nicht gelesen werden.",
     "class-project-error-build-docroot-not-found": "Es gibt kein Unterverzeichnis &quot;public_html&quot; oder &quot;public&quot; im Arbeitsverzeichnis.",
     "class-project-error-build-packaging-failed": "Build schlug beim Erstellen der Pakete fehl.",
     "class-project-error-command-failed": "Eines der Kommandos ist fehlgeschlagen (s. Fehlermeldung in der Ausgabe).<br>Frage ggf. den Administrator. Das Arbeitsverzeichnis wird f&uumlr eine Analyse nicht gel&ouml;scht.",
diff --git a/config/lang/en-en.json b/config/lang/en-en.json
index a909472a..c4a823bc 100644
--- a/config/lang/en-en.json
+++ b/config/lang/en-en.json
@@ -78,6 +78,7 @@
     "class-project-error-archivedir-empty": "ERROR::CONFIG: The archive directory ($aConfig[&quot;archiveDir&quot;]) is empty; it must point to a directory.",
     "class-project-error-build-dir-was-not-created": "The directory %s was not created.",
     "class-project-error-build-type-not-supported": "Repository type %s is not supported.",
+    "class-project-error-unable-to-read-vcs-metadata": "Unable to read vcs metadata.",
     "class-project-error-build-docroot-not-found": "There is no subdirectory &quot;public_html&quot; or &quot;public&quot; in the working directory.",
     "class-project-error-build-packaging-failed": "Build failed while creating the packages.",
     "class-project-error-command-failed": "The execution of a command failed (see error message in the output below).<br>Ask your admin. The working directory was NOT deleted that you can analyze the problem.",
-- 
GitLab


From b6d719d1a0bb468dd48155340bd9fd7b40dcd014 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Mon, 6 Jan 2025 16:32:13 +0100
Subject: [PATCH 3/3] Git: add --force on git fetch

---
 public_html/deployment/classes/vcs.git.class.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/public_html/deployment/classes/vcs.git.class.php b/public_html/deployment/classes/vcs.git.class.php
index 00b5020e..9302e88f 100644
--- a/public_html/deployment/classes/vcs.git.class.php
+++ b/public_html/deployment/classes/vcs.git.class.php
@@ -535,9 +535,10 @@ class vcs implements iVcs
             }
 
             // TODO: git 1.9 does needs only the line with --tags
+            // #7706 add --force
             $sGitCmd .= ' ( '
                 // . 'git fetch --update-head-ok --tags --depth 1 2>&1 ; ' // 1.5 s
-                . 'git fetch --update-head-ok --tags --depth 1 2>&1 ; ' // 1.5 s
+                . 'git fetch --update-head-ok --tags --depth 1 --force 2>&1 ; ' // 1.5 s
                 //. 'git fetch --update-head-ok --depth 1 2>&1 '          // 1.5 s
                 . ') && ';
         }
-- 
GitLab