From 0fb6c7a4bcd50c5ba09c81a53450e487510dc212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gr=C3=A9goire?= <gregoire.kubler@proton.me>
Date: Wed, 20 Nov 2024 16:28:30 +0100
Subject: [PATCH] feat: homoegeineized the API call to retrieve branches

---
 .gitlab/ci/download/select_jobs.gitlab-ci.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/.gitlab/ci/download/select_jobs.gitlab-ci.yml b/.gitlab/ci/download/select_jobs.gitlab-ci.yml
index 3b7622b..6cce7c6 100644
--- a/.gitlab/ci/download/select_jobs.gitlab-ci.yml
+++ b/.gitlab/ci/download/select_jobs.gitlab-ci.yml
@@ -55,14 +55,13 @@
         echo "*************************************************************************"
         echo "*************************************************************************"
         echo "**"
-        echo "**                    CHOOSING WHICH BRANCH TO PULL"
+        echo "**              CHOOSING WHICH BRANCH / RELEASE / REF TO PULL"
         echo "**"
         echo "*************************************************************************"
         echo "*************************************************************************"
         DEFAULT_BRANCH="dev"           # default branch to pull
         BRANCH_TO_PULL=$DEFAULT_BRANCH # default branch to pull
         echo "Default branch to pull : $BRANCH_TO_PULL"
-        echo "Retrieving branches of $DEP_NAME \"$DEP_API_URL/repository/branches\""
         echo "Choosing a branch / tag to pull dependending if we are in a Non draft merge request or not."
         echo "CI_COMMIT_TAG = $CI_COMMIT_TAG"
         echo "CI_MERGE_REQUEST_ID = $CI_MERGE_REQUEST_ID"
@@ -71,6 +70,7 @@
         ################################
         # CASE NON DRAFT MERGE REQUEST
         if [[ ! -z "$CI_MERGE_REQUEST_ID" && "$CI_MERGE_REQUEST_TITLE" != *'Draft'* ]]; then # case we are in a merge request
+          echo "Retrieving branches of $DEP_NAME \"$DEP_API_URL/repository/branches?per_page=100\""
         	DEP_BRANCHES=$(curl -s "$DEP_API_URL/repository/branches?per_page=100")
         	# If the MR is not in draft: pulling from target branch (if exists otherwise dev)
         	echo "NON DRAFT MERGE REQUEST Pipeline detected : Pulling from CI_MERGE_REQUEST_TARGET_BRANCH_NAME \"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME\"."
@@ -115,7 +115,8 @@
         # CASE CASUAL COMMIT or Draft MR PIPELINE
         else
         	# checking if a branch with same name exists in $DEP_NAME, otherwise, pulling from DEV
-        	DEP_BRANCHES=$(curl -s "$DEP_API_URL/repository/branches")
+          echo "Retrieving branches of $DEP_NAME \"$DEP_API_URL/repository/branches?per_page=100\""
+        	DEP_BRANCHES=$(curl -s "$DEP_API_URL/repository/branches?per_page=100")
         	echo "Looking for branch $CI_COMMIT_BRANCH in repo $DEP_NAME"
         	FILTERED_BRANCHES=$(jq --arg branch "$CI_COMMIT_REF_NAME" 'map(select( .name == $branch ))' <<<"$DEP_BRANCHES")
         	if [[ $(jq length <<<$FILTERED_BRANCHES) -gt 0 ]]; then
-- 
GitLab