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 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');