ci: preserve merge labels while state is unknown

This commit is contained in:
JerrettDavis 2026-07-09 19:51:41 -05:00
parent 595b709a5b
commit 2d418335a1
2 changed files with 19 additions and 11 deletions

View file

@ -204,17 +204,17 @@ jobs:
is_draft="$(jq -r '.isDraft' <<<"$data")"
review_decision="$(jq -r '.reviewDecision // ""' <<<"$data")"
if [[ "$merge_state" == "BEHIND" ]]; then
gh pr edit "$pr" --repo "$REPO" --add-label "status: needs rebase"
else
gh pr edit "$pr" --repo "$REPO" --remove-label "status: needs rebase" || true
fi
if [[ "$merge_state" == "DIRTY" ]]; then
gh pr edit "$pr" --repo "$REPO" --add-label "status: has conflicts"
else
gh pr edit "$pr" --repo "$REPO" --remove-label "status: has conflicts" || true
fi
if [[ "$merge_state" == "BEHIND" ]]; then
gh pr edit "$pr" --repo "$REPO" --add-label "status: needs rebase"
elif [[ "$merge_state" != "UNKNOWN" ]]; then
gh pr edit "$pr" --repo "$REPO" --remove-label "status: needs rebase" || true
fi
if [[ "$merge_state" == "DIRTY" ]]; then
gh pr edit "$pr" --repo "$REPO" --add-label "status: has conflicts"
elif [[ "$merge_state" != "UNKNOWN" ]]; then
gh pr edit "$pr" --repo "$REPO" --remove-label "status: has conflicts" || true
fi
if [[ "$check_state" == "failing" ]]; then
gh pr edit "$pr" --repo "$REPO" --add-label "status: ci failing"

View file

@ -22,3 +22,11 @@ def test_ready_for_review_label_is_removed_when_changes_are_requested() -> None:
assert "reviewDecision" in workflow
assert 'review_decision="$(jq -r \'.reviewDecision // ""\'' in workflow
assert '$review_decision" == "CHANGES_REQUESTED"' in workflow
def test_merge_state_unknown_does_not_clear_conflict_or_rebase_labels() -> None:
workflow = Path(".github/workflows/pr-health.yml").read_text(encoding="utf-8")
assert 'elif [[ "$merge_state" != "UNKNOWN" ]]; then' in workflow
assert 'gh pr edit "$pr" --repo "$REPO" --remove-label "status: needs rebase"' in workflow
assert 'gh pr edit "$pr" --repo "$REPO" --remove-label "status: has conflicts"' in workflow