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