Commit 2ded29b2 authored by Jan Kiene's avatar Jan Kiene
Browse files

change check for ref branch existing

parent 10744690
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -49,17 +49,17 @@ if ! [[ "$branchname" =~ $BASOP_PATTERN ]]; then
  exit 1
fi

float_ref_branchname="${branchname/basop/ref}"
git_result=$(git branch -av --list "$float_ref_branchname")

# If the branch does not exist, default to "float-pc"
if [[ -z "$git_result" ]]; then
  branchname="float-pc"
else
# The float ref branch is just the same name, but with basop -> ref replacement
# Replace only the first occurrence, as "basop" may be present in the later description
# If the format is correct, then before "_basop", only numbers can occur
float_ref_branchname="${branchname/basop/ref}"
git_result=$(git branch -av)

# If the branch does not exist, default to "float-pc"
if [[ "$git_result" =~ "$float_ref_branchname" ]]; then
  branchname="${float_ref_branchname}"
else
  branchname="float-pc"
fi

echo "$branchname"