Skip to content

Classify bare repos by structure, not directory name#263

Merged
sbertix merged 1 commit intomainfrom
sbertix/bare-repo
Apr 21, 2026
Merged

Classify bare repos by structure, not directory name#263
sbertix merged 1 commit intomainfrom
sbertix/bare-repo

Conversation

@sbertix
Copy link
Copy Markdown
Collaborator

@sbertix sbertix commented Apr 21, 2026

Summary

  • Repository.isGitRepository(at:) dropped the lastPathComponent.hasSuffix(".git") gate around the HEAD/objects/refs trio check, so user-renamed bare repos (e.g. myrepo-bare/) classify correctly instead of falling through to a folder. Matches git's own is_git_directory() heuristic. Follow-up to Add folder (non-git) repository support + harden removal pipeline #257 after user reports of bare repos being misclassified.
  • HEAD now must be a regular file (not a directory) — fileExists(atPath:isDirectory:) with a guard against the directory case — so a plain dir with three child dirs named HEAD/objects/refs is not a false positive.
  • Removed the now-obsolete repositoryClassificationLogger damaged-bare-clone warning. Its sole caller (the rejected .git-suffixed path) no longer exists as a distinct misclassification case.

Test plan

  • make check (swift-format + swiftlint, strict)
  • make test — 939 tests pass, 12 pre-existing known issues unchanged
  • New regression tests:
    • isGitRepositoryRecognizesBareRepositoryRegardlessOfName — HEAD+objects+refs at a non-*.git path → git
    • isGitRepositoryRejectsDirectoryMissingGitStructure — two of three trio members → folder
    • isGitRepositoryRejectsHeadDirectoryLookalike — HEAD/objects/refs all as directories → folder
    • isGitRepositoryReturnsFalseForNonexistentPath — vanished path → folder, no crash
  • Existing bare-clone / .bare / .git-pointer-file tests still pass unchanged

Drop the `lastPathComponent.hasSuffix(".git")` gate around the
HEAD/objects/refs trio check in `Repository.isGitRepository(at:)` so
bare repos whose directory name does not end in `.git` (e.g.
`myrepo-bare/`) classify correctly instead of falling through to a
folder. Matches git's own `is_git_directory()` heuristic. Also require
`HEAD` to be a regular file so a directory with three child dirs named
HEAD/objects/refs is not a false positive.
@sbertix sbertix enabled auto-merge (squash) April 21, 2026 08:35
@tuist
Copy link
Copy Markdown

tuist Bot commented Apr 21, 2026

🛠️ Tuist Run Report 🛠️

Builds 🔨

Scheme Status Duration Commit
supacode 1m 4s d3f88a970

@sbertix sbertix merged commit 393a855 into main Apr 21, 2026
2 checks passed
@sbertix sbertix deleted the sbertix/bare-repo branch April 21, 2026 08:39
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