From d8fc66e9bd27952d404d967f5d2ea2b1346d88ab Mon Sep 17 00:00:00 2001 From: Molecule AI Infra-SRE Date: Mon, 11 May 2026 15:42:05 +0000 Subject: [PATCH] fix(harness-replays): use github.sha not branch-name as HEAD for push events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: PR #497 used HEAD="${GITHUB_REF#refs/heads/}" (branch name) for push events. Gitea Compare API returns empty divergent-commits when comparing a SHA (github.event.before) with a branch name (main) in a linear history — the branch IS the commit's ancestor, so there are zero divergent commits. Fix: HEAD="${{ github.sha }}" — both BASE and HEAD are SHAs, so the API returns the pushed commits' changed files. Verified: compare/{before_sha}...{current_sha} correctly returns pushed commits on a linear push. For PR events, branch names still work correctly (the Compare API handles branch-vs-branch comparisons fine). Closes regression introduced in PR #497. Co-Authored-By: Claude Opus 4.7 --- .gitea/workflows/harness-replays.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/harness-replays.yml b/.gitea/workflows/harness-replays.yml index 380892fe..f26226b1 100644 --- a/.gitea/workflows/harness-replays.yml +++ b/.gitea/workflows/harness-replays.yml @@ -87,20 +87,19 @@ jobs: # Determine base and head refs for the Compare API call. # Gitea Compare API accepts branch names OR commit SHAs as base/head. # Pull request: base.ref + head.ref are in the event payload (branch names). - # Push: github.event.before (SHA of previous tip) as BASE, $GITHUB_REF - # (branch name) as HEAD. These are different, so the Compare API - # returns the actual diff — unlike the broken form which set both - # BASE and HEAD to the same branch name, making - # "compare/main...main" always return zero files. + # Push: github.event.before (SHA of previous tip) as BASE, github.sha + # (current tip SHA) as HEAD. Both SHAs means the API returns the + # pushed commits (unlike branch-name HEAD which returns empty in + # linear-history push events — Gitea treats SHA-vs-branch as + # "show divergent commits" and a linear push has zero of those). if [ "${{ github.event_name }}" = "pull_request" ]; then BASE="${{ github.event.pull_request.base.ref }}" HEAD="${{ github.event.pull_request.head.ref }}" elif [ -n "${{ github.event.before }}" ] && \ ! echo "${{ github.event.before }}" | grep -qE '^0+$'; then - # Push event: BASE = previous tip (SHA), HEAD = current branch name. + # Push event: BASE = previous tip (SHA), HEAD = current tip (SHA). BASE="${{ github.event.before }}" - HEAD_REF="${GITHUB_REF#refs/heads/}" - HEAD="${HEAD_REF:-main}" + HEAD="${{ github.sha }}" else # New branch or github.event.before unavailable — run everything. echo "run=true" >> "$GITHUB_OUTPUT"