Skip to content
Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions update-pr-stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ format_state_marker() {
# Echoes the most recent state-marker line found in our PR comments, or nothing.
read_state_marker() {
local PR_NUMBER="$1"
gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body' 2>/dev/null \
| { grep -F "$STATE_MARKER_PREFIX" || true; } | tail -n1
local BODIES
if ! BODIES=$(gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body'); then
echo "Error: could not read comments of PR #$PR_NUMBER" >&2
exit 1
fi
{ grep -F "$STATE_MARKER_PREFIX" <<<"$BODIES" || true; } | tail -n1
}

# Args: a marker line. Echoes "base target squash".
Expand Down Expand Up @@ -231,11 +235,15 @@ See $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
return 0
}

# Check if a PR has the conflict resolution label
# Check if a PR has the conflict resolution label. A failed labels fetch aborts
# the run rather than reading as "no label", which would silently skip a resume.
Comment thread
Phlogistique marked this conversation as resolved.
Outdated
pr_has_conflict_label() {
local PR_NUMBER="$1"
local LABELS
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' 2>/dev/null || echo "")
if ! LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name'); then
echo "Error: could not read labels of PR #$PR_NUMBER" >&2
exit 1
fi
echo "$LABELS" | grep -q "^${CONFLICT_LABEL}$"
}

Expand Down
Loading