Skip to content

[DIT-13467]: send git metadata with post v2scan - #155

Merged
laurakoye merged 3 commits into
laura/dit-13461-read-git-context-in-the-cli-scanfrom
laura/dit-13467-send-git-metadata-with-post-v2scan
Aug 20, 2026
Merged

[DIT-13467]: send git metadata with post v2scan#155
laurakoye merged 3 commits into
laura/dit-13461-read-git-context-in-the-cli-scanfrom
laura/dit-13467-send-git-metadata-with-post-v2scan

Conversation

@laurakoye

@laurakoye laurakoye commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Overview

Stacked on #154 — this diff is only the wiring.

ditto scan now tells the server which repo and commit it scanned, so a later scan can be matched against this one instead of importing every string again.

What POST /v2/scan sends:

  {
    "path": "/Users/laura/Desktop/Ditto/cli/lib/src/scan",
+   "repoKey": "github.com/dittowords/cli",
+   "gitCommitSha": "d3c1a8148580e1869c91ee6caadda17165ceb0ea",
+   "gitBranch": "laura/dit-13467-send-git-metadata-with-post-v2scan",
+   "repoRelativeRoot": "lib/src/scan"
  }

repoRelativeRoot is where the scan started inside the repo. Candidate paths come out relative to
the scanned directory, so ditto-app #9367 prefixes this root to build a repo-root-relative code link
path. "" when the scan is the repo root, and omitted if the scanned path somehow sits outside the
repo, so a bad value never becomes a wrong link.

Outside a git repo the body is unchanged from today, and the scan still runs:

[ditto scan] not a git repository - this scan can be imported but not re-synced

With uncommitted changes it runs too, with a note that the commit is approximate.

Safe to merge before the server reads any of this — zod strips unknown keys, so /v2/scan ignores the new fields today.

Context

  • DIT-13467. Blocked by DIT-13461 ([DIT-13461]: Read git context in the CLI scan #154).
  • repoRelativeRoot is the first of DIT-13468's fields, pulled forward so #9367 has its prefix. scannedPaths and scannedAllPaths stay in that ticket.
  • repoRoot and dirty are read but not sent: repoRoot is local-only — it only derives repoRelativeRoot — and dirty is a warning, not a field.

Test Plan

  • yarn test passes — buildInitiateScanBody covers the payload with and without git context, at the repo root, and outside the repo
  • ditto scan inside a repo completes as before
  • ditto scan in a directory that isn't a repo prints the warning and still completes

@laurakoye
laurakoye changed the base branch from master to laura/dit-13461-read-git-context-in-the-cli-scan August 19, 2026 17:56
@laurakoye laurakoye changed the title Laura/dit 13467 send git metadata with post v2scan [DIT-13467]: send git metadata with post v2scan Aug 19, 2026

@jholiga jholiga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment, I think we want to be passing the repo-relative root in the post /v2/scan body, so we can use it for building the codelinks

Comment thread lib/src/http/scan.ts
@laurakoye
laurakoye requested a review from jholiga August 20, 2026 16:38
@laurakoye
laurakoye merged commit 07701e7 into laura/dit-13461-read-git-context-in-the-cli-scan Aug 20, 2026
1 check passed
laurakoye added a commit that referenced this pull request Aug 20, 2026
* [DIT-13461]: Read git context in the CLI scan

* bumping

* comments

* Added -c commit.gpgsign=false to the temp repo's git calls so the tests don't break for teammates who sign commits by default + prettier

* comments making test file easier to understand

* bumping package and adding port test

* [DIT-13467]: send git metadata with post v2scan (#155)

* [DIT-13467]: Send git metadata with POST /v2/scan

* scanning a directory with no extractable strings now actually prints that warning

* repoRelativeRoot
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