fix(git): select USC Gitea login for PR merges (#516)
Some checks failed
ci/woodpecker/push/ci Pipeline failed
Some checks failed
ci/woodpecker/push/ci Pipeline failed
This commit is contained in:
@@ -69,6 +69,11 @@ if [[ -z "$PR_NUMBER" ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [[ ! "$PR_NUMBER" =~ ^[0-9]+$ ]]; then
|
||||
echo "Error: PR number must be numeric." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$MERGE_METHOD" != "squash" ]]; then
|
||||
echo "Error: Mosaic policy enforces squash merge only. Received '$MERGE_METHOD'." >&2
|
||||
exit 1
|
||||
@@ -94,19 +99,31 @@ REPO=$(get_repo_name)
|
||||
|
||||
case "$PLATFORM" in
|
||||
github)
|
||||
CMD="gh pr merge $PR_NUMBER --squash"
|
||||
[[ "$DELETE_BRANCH" == true ]] && CMD="$CMD --delete-branch"
|
||||
eval "$CMD"
|
||||
CMD=(gh pr merge "$PR_NUMBER" --squash)
|
||||
[[ "$DELETE_BRANCH" == true ]] && CMD+=(--delete-branch)
|
||||
"${CMD[@]}"
|
||||
;;
|
||||
gitea)
|
||||
CMD="tea pr merge $PR_NUMBER --style squash --repo $OWNER/$REPO --login ${GITEA_LOGIN:-mosaicstack}"
|
||||
HOST=$(get_remote_host) || {
|
||||
echo "Error: Could not determine remote host." >&2
|
||||
exit 1
|
||||
}
|
||||
CMD=(tea pr merge "$PR_NUMBER" --style squash --repo "$OWNER/$REPO")
|
||||
GITEA_TEA_LOGIN=$(get_gitea_login "$HOST" || true)
|
||||
if [[ -n "$GITEA_TEA_LOGIN" ]]; then
|
||||
if [[ ! "$GITEA_TEA_LOGIN" =~ ^[A-Za-z0-9._-]+$ ]]; then
|
||||
echo "Error: Gitea tea login contains unsupported characters." >&2
|
||||
exit 1
|
||||
fi
|
||||
CMD+=(--login "$GITEA_TEA_LOGIN")
|
||||
fi
|
||||
|
||||
# Delete branch after merge if requested
|
||||
if [[ "$DELETE_BRANCH" == true ]]; then
|
||||
echo "Note: Branch deletion after merge may need to be done separately with tea" >&2
|
||||
fi
|
||||
|
||||
eval "$CMD"
|
||||
"${CMD[@]}"
|
||||
;;
|
||||
*)
|
||||
echo "Error: Could not detect git platform" >&2
|
||||
|
||||
Reference in New Issue
Block a user