From a33729e4e50b58b8b35b6e25bbbbd9a236c49fd8 Mon Sep 17 00:00:00 2001 From: hyochan Date: Wed, 18 Nov 2026 16:47:00 +0900 Subject: [PATCH 1/2] fix(ci): fetch main by explicit refspec in tag builds Codemagic clones a tag with no remote-tracking branches, so `git fetch origin main` updated only FETCH_HEAD and origin/main never existed. The first ota-dry tag build failed its tip-of-main check that way, and scripts/ota-release.zsh would have failed the same check next. Fetch +refs/heads/main:refs/remotes/origin/main in both. Co-Authored-By: Claude Opus 5.5 --- codemagic.yaml | 4 ++-- scripts/ota-release.zsh | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/codemagic.yaml b/codemagic.yaml index 39ece84..3f911bf 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -69,7 +69,7 @@ definitions: if [ -z "${CM_TAG:-}" ]; then echo "Started by hand on $(git rev-parse --short HEAD)"; exit 0; fi # A shallow clone cannot prove ancestry. [ "$(git rev-parse --is-shallow-repository)" = false ] || git fetch --quiet --unshallow origin - git fetch --quiet origin main + git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main git merge-base --is-ancestor HEAD origin/main \ || { echo "Tag $CM_TAG is not on main"; exit 1; } - &require_version_tag @@ -308,7 +308,7 @@ workflows: - name: Require the tag to be the tip of main script: | set -euo pipefail - git fetch --quiet origin main + git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main [ "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" ] \ || { echo "OTA must publish the current main; ${CM_TAG:-this commit} is not its tip"; exit 1; } # ota-release.zsh insists on the main branch; a tag build is detached. diff --git a/scripts/ota-release.zsh b/scripts/ota-release.zsh index e7eb8b7..833bb91 100755 --- a/scripts/ota-release.zsh +++ b/scripts/ota-release.zsh @@ -35,7 +35,9 @@ if [[ -n "$(git status --porcelain)" ]]; then exit 1 fi -git fetch --quiet origin main +# An explicit refspec: a CI clone of a tag may have no remote-tracking branches, +# and a bare `fetch origin main` then updates only FETCH_HEAD. +git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main local_head="$(git rev-parse HEAD)" remote_head="$(git rev-parse origin/main)" if [[ "$local_head" != "$remote_head" ]]; then From 566ac357456ba71e76388135b03c32a79a92f948 Mon Sep 17 00:00:00 2001 From: hyochan Date: Wed, 18 Nov 2026 16:47:54 +0900 Subject: [PATCH 2/2] test(release): expect the explicit main refspec Co-Authored-By: Claude Opus 5.5 --- test/release/otaRelease.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/release/otaRelease.test.ts b/test/release/otaRelease.test.ts index 80cf6ba..02cdc16 100644 --- a/test/release/otaRelease.test.ts +++ b/test/release/otaRelease.test.ts @@ -50,7 +50,9 @@ describe('production OTA release contract', () => { it('requires a clean checkout at the exact latest main commit', () => { expect(script).toContain('git branch --show-current'); expect(script).toContain('git status --porcelain'); - expect(script).toContain('git fetch --quiet origin main'); + expect(script).toContain( + 'git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main', + ); expect(script).toContain('git rev-parse origin/main'); expect(script).toContain('if [[ "$local_head" != "$remote_head" ]]'); expect(script).toContain('gh run list');