Skip to content

fix: repo directory name collisions and custom directory support#241

Merged
chriswritescode-dev merged 3 commits into
mainfrom
fix/repo-directory-name-collisions
May 30, 2026
Merged

fix: repo directory name collisions and custom directory support#241
chriswritescode-dev merged 3 commits into
mainfrom
fix/repo-directory-name-collisions

Conversation

@chriswritescode-dev
Copy link
Copy Markdown
Owner

Summary

  • Allow users to specify a custom directory name when adding a remote repo, preventing collisions when cloning a fork of an already-cloned repo (e.g., forker/repo when owner/repo exists)
  • Add shared validation and normalization utilities (shared/src/utils/repo.ts) for directory name sanitization, URL normalization, and path safety, used by both frontend and backend — replaces duplicated sanitizeWorkspaceAliasSegment in backend
  • Backend validates directoryName before using it as a filesystem path (rejects path separators, dot-dot segments, absolute paths, invalid characters)
  • Frontend detects directory collisions by normalizing both existing and new repo URLs (SSH/HTTPS/shorthand), shows inline warning, and disables submit until resolved
  • Move SSH credential setup after DB record creation to avoid premature setup when repo already exists

Validation

  • pnpm lint:frontend
  • pnpm lint:backend
  • pnpm test

Files

  • backend/src/routes/repos.ts | 4 +-
  • backend/src/services/repo.ts | 32 ++++-----
  • frontend/src/api/repos.ts | 1 +
  • frontend/src/components/repo/AddRepoDialog.tsx | 88 +++++++++++++++-
  • shared/src/schemas/repo.ts | 1 +
  • shared/src/utils/index.ts | 1 +
  • shared/src/utils/repo.ts | 82 +++++++++++++++ (new)
    7 files changed, 187 insertions(+), 29 deletions(-)

Allow users to specify a custom directory name when adding a remote repo, preventing collisions when cloning a fork of an already-cloned repo.

- Add shared validation and normalization utilities (shared/src/utils/repo.ts)
  for directory name sanitization, URL normalization, and path safety
- Replace duplicated sanitizeWorkspaceAliasSegment with shared helper
- Backend validates directoryName before use as filesystem path
- Frontend detects directory collisions with normalized URL comparison
- Move SSH credential setup after DB record creation
Comment thread shared/src/utils/repo.ts Fixed
Comment thread shared/src/utils/repo.ts Fixed
Comment thread shared/src/utils/repo.ts Fixed
@chriswritescode-dev chriswritescode-dev merged commit 60ed756 into main May 30, 2026
4 checks passed
@chriswritescode-dev chriswritescode-dev deleted the fix/repo-directory-name-collisions branch May 30, 2026 23:12
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