[DIT-13461]: Read git context in the CLI scan - #154
Merged
laurakoye merged 7 commits intoAug 20, 2026
Conversation
…ts don't break for teammates who sign commits by default + prettier
3 tasks
jholiga
approved these changes
Aug 20, 2026
jholiga
left a comment
Contributor
There was a problem hiding this comment.
Just found one edge case with the regex for SCP, otherwise looks good!
| * The scp-like remote form `git@github.com:Ditto/App.git`, which has no scheme | ||
| * and so isn't a URL. Captures the host and the path around the colon. | ||
| */ | ||
| const SCP_LIKE = /^(?:[^/@]+@)?([^/:]+):(.+)$/; |
Contributor
There was a problem hiding this comment.
Should we handle the edge case of if there's a port in the path, like git@github.com:2222/ditto/app.git?
Contributor
|
Oh also don't forget to bump the version! |
* [DIT-13467]: Send git metadata with POST /v2/scan * scanning a directory with no extractable strings now actually prints that warning * repoRelativeRoot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
New file
lib/src/scan/git.ts— reads which repo and commit a scan came from, so a second scan can recognize a codebase Ditto has already seen.normalizeRepoKeygives one stable key regardless of clone style, and credentials can't leak into it:git@github.com:Ditto/App.gitgithub.com/ditto/apphttps://github.com/ditto/app.gitgithub.com/ditto/apphttps://user:token@github.com/ditto/app.gitgithub.com/ditto/appgit@gitlab.com:group/subgroup/app.gitgitlab.com/group/subgroup/appKeys are validated against
REPO_KEY_PATTERN, copied fromditto-app(shared/types/ProductTextDetection.ts:46).Nothing throws: no git, no repo, no commits, or no
originall returnnull. No new dependency —node:child_process.Nothing calls this yet. #155 wires it into
POST /v2/scan, soditto scanis unchanged here.Context
@dittowords/text-extractto^0.3.0so the scan picks up the shipped extractor work. The CLI imports onlyrunExtractand two types, so nothing breaking reaches it — but candidate ids all change, sincemakeCandidateIdnow hashesfile:value:occurrence_index.Test Plan
yarn testpasses —git.test.tscovers the URL forms above, a detached HEAD, a dirty tree, and thenullcases;extract.test.tscovers the0.3.0bumpditto scanoutput unchanged frommaster