Skip to content

test(worktree): seed orphan worktrees without git 2.42 - #1925

Open
Giraffe0129 wants to merge 1 commit into
Tencent:mainfrom
Giraffe0129:fix/git-239-orphan-worktrees
Open

Giraffe0129 wants to merge 1 commit into
Tencent:mainfrom
Giraffe0129:fix/git-239-orphan-worktrees

Conversation

@Giraffe0129

Copy link
Copy Markdown

Summary

The suite still supports git 2.39 (#1008), but two tests create worktrees with
git worktree add --orphan, which only exists from git 2.42 on. On git 2.39 uninstall.test.ts
fails with error: unknown option 'orphan' and the hooks E2E fails in
git ... worktree add --orphan, so contributors on an older git see red tests unrelated to
their change. This reaches the same end state without that flag, the way product code already
falls back (src/utils/branch-worktree.ts): a detached worktree plus checkout --orphan for the
uninstall case, and one seed commit in the bare repo with a branch per worktree for the E2E.
Tests only — no product code changes.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

Run on Windows 11, git 2.50, Node 24.13:

Check Result
npx tsc --noEmit passes
npx oxlint -c .oxlintrc.json on the two changed files 0 warnings, 0 errors
npx vitest run uninstall -t "side branch" 2 passed (both it.each variants)
npx vitest run --config vitest.e2e.config.ts hooks-project-isolation-issue373 -t "removes only the caller hook file" --retry 0 1 passed
whole hooks-project-isolation-issue373 file 30 passed, 1 failed: spawnSync sh ENOENT at :225 — that case shells out to POSIX sh, unrelated to this change and Windows-only

The assertions are unchanged, so the end state is still checked: the uninstall case still requires
the linked worktree and .git/worktrees to be gone and teamai-learnings to be deleted or kept;
the seeded orphan branch still has no parent (git rev-list --count --max-parents=0 HEAD = 1).

Not checked:

  • git 2.39 itself — no Docker daemon here, and downloading a portable 2.39 was blocked. The removed
    worktree add --orphan is the only 2.42+ API involved; its replacements (worktree add --detach,
    checkout --orphan, worktree add -b <branch> <path> <commit-ish>, push HEAD:refs/heads/main)
    all exist long before 2.39.

  • Full npm run lint — reports 26 pre-existing teamai(family-facts) errors under
    packages/tool-*/src/facts.ts, none of which this PR touches (they are present at 2660cfc).
    Lint scoped to the changed files is clean.

  • npx tsc --noEmit passes

  • npm run lint passes

  • The test files that cover what I changed pass

  • Added/updated tests for the change

  • Runtime change (npm run verify:world) — not needed for a tests-only change

Related Issues

Part of #1889. Does not close it: the other four items in that issue are covered by separate PRs.

Notes for Reviewers

  • Dropping --orphan is the point: it is the only thing here that needs git > 2.39, and product
    code avoids it the same way (src/utils/branch-worktree.ts:793-819).
  • In the E2E the bare repo now starts with one empty commit (bare-seed), so each worktree is on
    its own branch instead of an unborn HEAD. The case only needs two live bare worktrees with hook
    files, and no assertion changes.
  • The uninstall case keeps the "orphan branch with no parent" shape by detaching first and then
    checking out the orphan branch; its follow-up commits and the kept-vs-deleted assertions are
    untouched.

`git worktree add --orphan` needs git 2.42, but the suite still supports git 2.39 (Tencent#1008). Seed the worktrees the way product code falls back to: detach, then check out an orphan branch; and in the hooks E2E, push one empty commit into the bare repo and branch each worktree off it.

Part of Tencent#1889.
@Giraffe0129

Copy link
Copy Markdown
Author

Hi @jeff-r2026 , the PR is ready and all CI checks have passed. Could you please take a look when you have time? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants