perf: skip redundant alias identity probes

This commit is contained in:
Gergo Magyar 2026-11-07 06:42:17 +00:00
parent 8482d42d43
commit 07dfbc979e
2 changed files with 3 additions and 3 deletions

View file

@ -1482,8 +1482,8 @@ async function preparedAnalysisName(repoPath: string, options: AnalyzeOptions):
if (
existing &&
existing.name !== path.basename(path.resolve(existing.path)) &&
existing.name !== path.basename(resolveRepoIdentityRoot(existing.path)) &&
existing.name !== inferred
existing.name !== inferred &&
existing.name !== path.basename(resolveRepoIdentityRoot(existing.path))
)
return existing.name;
return inferred ?? path.basename(resolveRepoIdentityRoot(repoPath));

View file

@ -944,6 +944,7 @@ export class RegistryNameCollisionError extends Error {
const hasCustomAlias = (entry: RegistryEntry, inferredName: string | null): boolean => {
const resolved = path.resolve(entry.path);
if (entry.name === path.basename(resolved)) return false;
if (inferredName && entry.name === inferredName) return false;
// Canonical-root-derived names are not user aliases either (#1259):
// a worktree registered under the canonical repo's basename
// (e.g. `{name: 'repo', path: '/repo/wt-feature'}`) must re-register
@ -955,7 +956,6 @@ const hasCustomAlias = (entry: RegistryEntry, inferredName: string | null): bool
// — analyze canonical, then analyze worktree, then re-analyze worktree
// — would break on the third call.
if (entry.name === path.basename(resolveRepoIdentityRoot(resolved))) return false;
if (inferredName && entry.name === inferredName) return false;
return true;
};