fix(workspace-cleanup): never take a tag as a workspace's base

This commit is contained in:
Kelvin Amoaba
2026-11-12 06:43:58 +00:00
parent 2133d6e09e
commit 62a24a5b73
2 changed files with 14 additions and 1 deletions
@@ -156,6 +156,17 @@ describe('workspace cleanup merge evidence against real Git', () => {
expect((await readEvidence(undefined, 'main')).blockers).toEqual(['unpushed-commits'])
})
it('never takes a tag as the base', async () => {
await commitFile(worktreePath, 'a.txt')
await git(['tag', 'release'], worktreePath)
expect(await readEvidence('release')).toEqual({
blockers: ['unpushed-commits'],
merge: { headInDefaultBranch: false, aheadOfDefault: 1 },
reasons: []
})
})
it('keeps unpushed risk for local commits that never landed', async () => {
await commitFile(worktreePath, 'a.txt')
@@ -125,7 +125,9 @@ async function resolveBranchBaseOid(
ref,
async (candidate) => (await resolveCommitOid(git, candidate)) !== null
)
if (branchName && worktreeBaseRefFamily(qualified) === branchName) {
const family = worktreeBaseRefFamily(qualified)
// Only a branch can hold landed work; a tag or a name that resolves to nothing is not a base.
if (family === null || family === branchName) {
return null
}
return resolveCommitOid(git, qualified)