Skip to content

Commit 5ea92cc

Browse files
authored
tools: bump-omicron checks to avoid using an old main (#3058)
bump-omicron script: check to avoid using an old main
1 parent 7e3ca93 commit 5ea92cc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/deno/bump-omicron.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,15 @@ async function makeOmicronPR(
160160
// wrapped in a function so we can do early returns rather than early
161161
// Deno.exits, which mess up the worktree cleanup
162162
async function run(commitIsh: string, dryRun: boolean, messageArg: string | undefined) {
163-
await $`git fetch`.cwd(OMICRON_DIR)
163+
// Ensure local main matches the remote so we don't bump to a stale commit
164+
if (commitIsh === 'main') {
165+
const localMain = await $`git rev-parse main`.text()
166+
const remoteMain = await $`git ls-remote origin main`.text()
167+
const remoteMainSha = remoteMain.split('\t')[0]
168+
if (localMain !== remoteMainSha) {
169+
throw new Error('Local main does not match remote. Fetch main and try again.')
170+
}
171+
}
164172

165173
const oldConsoleCommit = await getOldCommit()
166174
const newConsoleCommit = await $`git rev-parse ${commitIsh}`.text()

0 commit comments

Comments
 (0)