From f82aedd302fd1616cb2ea6abf1c77a418f4baea1 Mon Sep 17 00:00:00 2001 From: Jason Huebert Date: Sat, 3 Oct 2026 17:03:00 -0500 Subject: [PATCH] ci: promote from the revision that was actually verified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A stable_source branch that exists only as origin/ passed the rev-parse check, then git cherry was handed the nonexistent local name and failed — with `|| true` around the pipeline that became an empty pick list, so the promotion published stable without a single commit from the branch it was dispatched for. The README was taken from repeater-filter in that case too. The verified revision is now resolved once and used for the cherry and for the fork README, which also covers a source branch that is the one checked out in this worktree (git branch --force would refuse that). git cherry runs on its own so a real failure aborts the step instead of looking like "nothing to pick". Verified against throwaway repositories: the default source, a source that exists only on the remote, and an unknown source that is refused with stable untouched. --- .github/workflows/sync-upstream.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 8bf123f5..53c45a2e 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -168,10 +168,15 @@ jobs: run: | set -euo pipefail SOURCE="${STABLE_SOURCE:-repeater-filter}" - if ! git rev-parse --verify "refs/remotes/origin/$SOURCE" >/dev/null; then + if ! SOURCE_SHA=$(git rev-parse --verify "refs/remotes/origin/$SOURCE"); then echo "No such branch to promote from: $SOURCE" >&2 exit 1 fi + # git cherry and `git checkout -- README.md` both work from the + # verified revision directly. Resolving it to a SHA is what keeps a + # source branch that exists only as origin/ from failing the + # cherry: the branch may well be the one checked out here, and a + # `git branch --force` for it would be refused. STABLE_BEFORE=$(git rev-parse refs/remotes/origin/repeater-filter-stable) # Everything happens on a scratch branch. The real stable branch is @@ -185,7 +190,7 @@ jobs: # never lands in an intermediate commit just to be overwritten later. if ! git merge origin/main --no-commit --no-ff; then git diff --name-only --diff-filter=U > stable-conflicted-files.txt || true - git checkout repeater-filter -- README.md + git checkout "$SOURCE_SHA" -- README.md if [ -n "$(git diff --name-only --diff-filter=U)" ]; then git merge --abort || true echo "conflict=true" >> $GITHUB_OUTPUT @@ -193,14 +198,19 @@ jobs: exit 1 fi fi - git checkout repeater-filter -- README.md + git checkout "$SOURCE_SHA" -- README.md if [ -f .git/MERGE_HEAD ]; then git commit --no-edit fi # cherry-pick the filter commits not yet on stable (git cherry matches - # by patch-id, so already-picked commits are skipped); oldest first - PICKS=$(git cherry HEAD "$SOURCE" origin/dev | grep '^+' | cut -d' ' -f2 || true) + # by patch-id, so already-picked commits are skipped); oldest first. + # git cherry is called on its own so a failure of it aborts the step + # under `set -e`: with the whole pipeline guarded, a git error and a + # genuine "nothing to pick" are indistinguishable, and the second would + # publish a promotion that silently contained none of its commits. + CHERRY=$(git cherry HEAD "$SOURCE_SHA" origin/dev) + PICKS=$(printf '%s\n' "$CHERRY" | grep '^+' | cut -d' ' -f2 || true) PICK_COUNT=0 for c in $PICKS; do # skip fork-owned-README-only commits; the README is synced below @@ -220,7 +230,7 @@ jobs: done # keep the fork-owned README in step with the source branch - git checkout repeater-filter -- README.md + git checkout "$SOURCE_SHA" -- README.md git add -A if ! git diff --cached --quiet; then git commit -m "docs: sync fork README"