Skip to content

Recognise SSH GitHub remotes when scanning the dev directory [patch] - #471

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/441-ssh-remotes
Oct 6, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/441-ssh-remotes

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #441

What changed

GitHubRepository.IsRemotePathValid accepted only remotes that start with https://github.com/ (an ordinal comparison). As a result, "Scan Dev Dir" dropped every repository cloned over SSH and logged nothing, even though git operations go through the credential helper and SSH agent precisely so that SSH remotes work. The scan also worked out owner and repo by splitting the remote on / and reversing the parts, so a trailing / produced an empty repo name.

  • New GitHubRepository.TryParseRemote(remote, out owner, out repo) reads the owner and repo from:

    Each form is accepted with or without .git and a trailing /. The scheme and host are compared ignoring case; the owner and repo are kept as written. Anything other than exactly two non-empty path segments is rejected.

  • IsRemotePathValid and the dev-dir scan both use it. The split-and-reverse parsing is gone.

  • The scan now logs each working tree it skips: Skipped <dir>: origin <url> is not a GitHub repository.

Tests

New GitHubRemoteTests:

  • EveryGitHubRemoteFormYieldsItsOwnerAndRepository has 13 rows: every form, with and without .git and /, plus mixed-case hosts.
  • AnythingElseIsNotAGitHubRemote covers other hosts, a look-alike host (github.com.evil.example), a missing or empty segment, a /tree/main URL, and a local path.
  • AnSshCloneCreatesAGitHubRepository checks that GitRepository.Create no longer returns null for an scp-style remote.

Results:

  • With the parser restricted to the old behaviour (https://github.com/ only, ordinal), 10 of the new cases fail.
  • With the change, 126 of 128 pass and 1 is skipped. The one failure is the pre-existing CloningAnLfsRepositoryRestoresTheFileContentRatherThanThePointer, which fails the same way on unchanged main in this sandbox.
  • dotnet format --verify-no-changes reports two issues in ProjectDirector.cs: import ordering, and IDE0001 near line 1218. Both exist on main and are outside the lines this PR changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV


Generated by Claude Code

IsRemotePathValid accepted only https://github.com/ remotes, so Scan Dev
Dir silently dropped every repository cloned over SSH. The scan also
derived owner and repo by splitting on '/' and reversing, which a
trailing slash broke.

GitHubRepository.TryParseRemote now reads owner and repo from the https,
scp-style ([email protected]:) and ssh:// forms, with or without .git and a
trailing slash, comparing the host ignoring case. Both IsRemotePathValid
and the scan use it, and the scan logs each remote it skips.

Fixes #441

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CaZMWc5xm4vDRcyMefDXyV
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit ea97034 into main Oct 6, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/441-ssh-remotes branch October 6, 2026 12:34
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.

"Scan Dev Dir" silently skips every repo cloned over SSH ([email protected]: / ssh:// remotes)

2 participants