fix(omz): fix cmr target-branch argument parsing

This commit is contained in:
Oliver
2026-03-13 15:10:33 +01:00
parent a762f1e557
commit c6efb6264e

View File

@@ -177,39 +177,50 @@ function gcmr() {
}
function cmr() {
if [[ "$*" == "--draft" ]]
then
draft="--draft"
else
draft=""
fi
local draft=""
local target_branch=""
local reviewer=""
reviewers=""
if [[ $1 =~ .*",".* ]]; then
reviewers="--reviewer=$1";
fi;
while [[ $# -gt 0 ]]; do
case "$1" in
--draft)
draft="--draft"
;;
--target-branch=*)
target_branch="${1#--target-branch=}"
;;
--target-branch)
target_branch="$2"
shift
;;
*)
reviewer="$1"
;;
esac
shift
done
current_branch=$(git branch --show-current)
if [[ $current_branch == "master" ]] || [[ $current_branch == "beta" ]] || [[ $current_branch == "acceptance" ]] || [[ $current_branch == "main" ]] || [[ $current_branch == "release" ]] ;
then echo "Checkout a feature branch" && return;
fi;
# Check if 'main' branch exists in the remote repository
current_project=$(basename $(pwd))
if [[ ! -z $2 ]]; then
target_branch=$2
elif [[ $current_project =~ "vrm-(front|api)" ]]; then
target_branch="release"
else
target_branch="master"
if [[ $current_branch == "master" ]] || [[ $current_branch == "beta" ]] || [[ $current_branch == "acceptance" ]] || [[ $current_branch == "main" ]] || [[ $current_branch == "release" ]]; then
echo "Checkout a feature branch" && return
fi
if [[ $1 == "--target-branch" ]]; then
target_branch=$2
fi;
if [[ -z "$target_branch" ]]; then
current_project=$(basename $(pwd))
local pattern="vrm-(front|api)"
if [[ $current_project =~ $pattern ]]; then
target_branch="release"
else
target_branch="master"
fi
fi
glab mr create -a oliver $reviewers --target-branch=$target_branch -t "Merge branch: '$(git branch --show-current)' into $target_branch" --fill -y $draft
local reviewers_arg=""
if [[ -n "$reviewer" ]]; then
reviewers_arg="--reviewer=$reviewer"
fi
glab mr create -a oliver $reviewers_arg --target-branch=$target_branch -t "Merge branch: '$(git branch --show-current)' into $target_branch" --fill -y $draft
}
function glisu() {