Skip to content

fix: resolve git origin in linked worktrees (Tia storage key + baseline fetch) - #1820

Draft
dammyammy wants to merge 1 commit into
pestphp:5.xfrom
dammyammy:fix/tia-worktree-origin-resolution
Draft

fix: resolve git origin in linked worktrees (Tia storage key + baseline fetch)#1820
dammyammy wants to merge 1 commit into
pestphp:5.xfrom
dammyammy:fix/tia-worktree-origin-resolution

Conversation

@dammyammy

Copy link
Copy Markdown

Problem

In a linked git worktree, .git is a file (a gitdir: pointer), not a directory. Two Tia code paths read $projectRoot/.git/config directly and therefore silently fail in every worktree:

  1. Storage::rawOriginUrl() — the storage key falls back to a realpath hash instead of the origin identity. The docs state worktrees of the same repository share one cache; today they don't.
  2. BaselineSync::detectGitHubRepo() — returns null, so --tia --baselined silently skips the CI baseline fetch and falls back to a full local re-record, exactly in the throwaway checkouts (agent/CI worktrees) where a fetched baseline helps most.

Measured on v5.0.2:

# main checkout
$ vendor/bin/pest --baseline
/Users/x/.pest/tia/repo-840a07cab1e2d72d        # origin-derived hash

# linked worktree of the same repo (before this fix)
$ vendor/bin/pest --baseline
/Users/x/.pest/tia/wt-feee7be378801f90          # realpath hash — origin ignored

# linked worktree (after this fix)
$ vendor/bin/pest --baseline
/Users/x/.pest/tia/wt-840a07cab1e2d72d          # origin-derived hash again

Fix

Keep the fast .git/config file read for regular checkouts; when .git is not a directory, fall back to git config --get remote.origin.url executed inside the project root (5s timeout, failures degrade to the existing null behaviour).

Notes for review

  • Storage::projectKey() still prefixes slug(basename($projectRoot)), so two worktrees end up with sibling storage dirs (wt-a-<hash>, wt-b-<hash>) rather than literally one shared dir. If full sharing is the intent of the docs, the slug would also need to derive from the origin identity — happy to extend the PR that way if preferred; keeping keys per-worktree does avoid concurrent runs in different worktrees racing on one graph.json.
  • With this fix, --baselined works from worktrees, which covers the main practical need (fresh worktrees replaying from the CI baseline in seconds).

Draft — description/scope still being refined.

…aseline fetch

In a linked git worktree, .git is a file pointing at the real git dir, so
reading $projectRoot/.git/config directly fails. Both Storage::rawOriginUrl()
and BaselineSync::detectGitHubRepo() bail out silently as a result:

- the storage key falls back to a realpath hash, so worktrees of the same
  repository do not share the documented origin-derived project key, and
- --tia --baselined silently skips the CI baseline fetch in every worktree.

Keep the fast .git/config file read for regular checkouts and fall back to
`git config --get remote.origin.url` (run inside the project root) when
.git is not a directory.
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.

1 participant