From e92e22899bd6f213062c219c1c74527438a2a010 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Wed, 20 Dec 2023 14:36:25 +0100
Subject: [PATCH] new feature: button to set branch of next phase

---
 public_html/deployment/pages/act_build.php | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/public_html/deployment/pages/act_build.php b/public_html/deployment/pages/act_build.php
index 0e2c0017..e22bc21c 100644
--- a/public_html/deployment/pages/act_build.php
+++ b/public_html/deployment/pages/act_build.php
@@ -36,6 +36,8 @@ if (!array_key_exists("confirm", $aParams)) {
     // ------------------------------------------------------------
     $sNext = $oPrj->getNextPhase();
     $aPhaseData2 = $oPrj->getPhaseInfos($sNext);
+    $sBranchontarget=isset($aPhaseData2["ready2install"]["branch"]) ? $aPhaseData2["ready2install"]["branch"]: '';
+    print_r($sBranchname);
     $bIgnoreCache = isset($aParams['reloadBranches']) ? $aParams['reloadBranches'] : false;
 
     // $sOut.='<p>Re-Read Branches (ignore caching) - '.($bIgnoreCache ? "JA" : "mein" ).'</p>';
@@ -70,7 +72,20 @@ if (!array_key_exists("confirm", $aParams)) {
                  <tr>
                      <td class="">
                          ' . $oPrj->renderSelectRemoteBranches(false, $bIgnoreCache) . '
-                         <form action="?" method="post" enctype="multipart/form-data">
+                         '.(
+                            $sBranchontarget && $sBranchontarget != $sBranchname
+                             ? '
+                             <form action="?" method="post" enctype="multipart/form-data">
+                                 <input type="hidden" name="reloadBranches" value="1">
+                                 <input type="hidden" name="branchname" value="' . $sBranchontarget . '">
+                                    '.sprintf(t('page-build-branch-on-target'), $sBranchontarget).'<br>
+                                     <button type="submit" class="btn btn-default">' . sprintf(t('page-build-switch-to-target'), $sBranchontarget) . '</button>
+                             </form>
+                             <br><hr>
+                             '
+                             : ''
+                         ).'
+                          <form action="?" method="post" enctype="multipart/form-data">
                             <input type="hidden" name="reloadBranches" value="1">
                             <input type="hidden" name="branchname" value="' . $sBranchname . '">
                             <fieldset>
-- 
GitLab