mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 08:03:13 +00:00
fix(worktree): only dedupe a linked worktree against a git main checkout
Review follow-up: the repos:add guard matched any tracked repo on the main checkout path, including a folder-kind record. A folder repo does not project onto the same project as the git worktree, so matching it would suppress a legitimate add without deduping anything.
This commit is contained in:
@@ -167,6 +167,18 @@ describe('repos:add with git worktrees', () => {
|
||||
expect(mockStore.addRepo).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not match a folder record sitting on the main-checkout path', async () => {
|
||||
mockStore.getRepos.mockReturnValue([
|
||||
{ ...trackedMainRepo(), id: 'folder-repo-id', kind: 'folder' } as Repo
|
||||
])
|
||||
getLinkedWorktreeMainRepoRootMock.mockReturnValue(MAIN_CHECKOUT)
|
||||
|
||||
const result = await callAdd({ path: LINKED_WORKTREE })
|
||||
|
||||
expect(mockStore.addRepo).toHaveBeenCalledTimes(1)
|
||||
expect(result).toEqual({ repo: expect.objectContaining({ path: LINKED_WORKTREE }) })
|
||||
})
|
||||
|
||||
it('does not match a tracked SSH repo that shares the local main-checkout path', async () => {
|
||||
mockStore.getRepos.mockReturnValue([
|
||||
{ ...trackedMainRepo(), id: 'ssh-repo-id', connectionId: 'builder' } as Repo
|
||||
|
||||
@@ -203,11 +203,15 @@ async function addLocalRepoFromPath(
|
||||
const mainRepoRoot = getLinkedWorktreeMainRepoRoot(resolvedPath)
|
||||
if (mainRepoRoot) {
|
||||
const mainRepoKey = normalizeRuntimePathForComparison(mainRepoRoot)
|
||||
// Why !isFolderRepo: only a git-kind main checkout projects onto the same project as its
|
||||
// worktree, so matching a folder record would suppress the add without deduping anything.
|
||||
const trackedMainRepo = store
|
||||
.getRepos()
|
||||
.find(
|
||||
(repo) =>
|
||||
!repo.connectionId && normalizeRuntimePathForComparison(repo.path) === mainRepoKey
|
||||
!repo.connectionId &&
|
||||
!isFolderRepo(repo) &&
|
||||
normalizeRuntimePathForComparison(repo.path) === mainRepoKey
|
||||
)
|
||||
if (trackedMainRepo) {
|
||||
return { repo: trackedMainRepo, alreadyExisted: true }
|
||||
|
||||
Reference in New Issue
Block a user