44# Function to calculate the corresponding branch of Xetabase project
55get_xetabase_branch () {
66 # Input parameter (branch name)
7- input_branch=" $1 "
7+ # Input parameter (branch name)
8+ target_branch=" $1 "
9+ current_branch=" $2 "
810
911 # If the branch begins with 'TASK' and exists in the opencga-enterprise repository, I return it
10- if [[ $input_branch == TASK* ]]; then
11- if [ " $( git ls-remote " https://$ZETTA_REPO_ACCESS_TOKEN @github.com/zetta-genomics/opencga-enterprise.git" " $input_branch " ) " ] ; then
12- echo $input_branch ;
12+ if [[ $current_branch == TASK* ]]; then
13+ if [ " $( git ls-remote " https://$ZETTA_REPO_ACCESS_TOKEN @github.com/zetta-genomics/opencga-enterprise.git" " $current_branch " ) " ] ; then
14+ echo " $current_branch " ;
1315 return 0;
1416 fi
1517 fi
1618
1719 # Check if the branch name is "develop" in that case return the same branch name
18- if [[ " $input_branch " == " develop" ]]; then
20+ if [[ " $target_branch " == " develop" ]]; then
1921 echo " develop"
2022 return 0
2123 fi
2224
2325 # Check if the branch name starts with "release-" and follows the patterns "release-a.x.x" or "release-a.b.x"
24- if [[ " $input_branch " =~ ^release-([0-9]+)\. x\. x$ ]] || [[ " $input_branch " =~ ^release-([0-9]+)\. ([0-9]+)\. x$ ]]; then
26+ if [[ " $target_branch " =~ ^release-([0-9]+)\. x\. x$ ]] || [[ " $target_branch " =~ ^release-([0-9]+)\. ([0-9]+)\. x$ ]]; then
2527 # Extract the MAJOR part of the branch name
2628 MAJOR=${BASH_REMATCH[1]}
2729 # Calculate the XETABASE_MAJOR by subtracting 3 from MAJOR
@@ -32,7 +34,7 @@ get_xetabase_branch() {
3234 return 1
3335 fi
3436 # Construct and echo the new branch name
35- echo " release-$XETABASE_MAJOR .${input_branch # release-$MAJOR .} "
37+ echo " release-$XETABASE_MAJOR .${target_branch # release-$MAJOR .} "
3638 return 0
3739 fi
3840
@@ -41,6 +43,11 @@ get_xetabase_branch() {
4143 return 1
4244}
4345
46+ # Check if the script receives exactly one argument
47+ if [ " $# " -ne 2 ]; then
48+ echo " Usage: $0 <target-branch> <current-branch>"
49+ exit 1
50+ fi
4451
4552# Call the function with the input branch name
46- get_xetabase_branch " $1 "
53+ get_xetabase_branch " $1 " " $2 "
0 commit comments