feat(release): filter set-commits by path for monorepos (CLI-339)#1159
Merged
Conversation
In a monorepo, `set-commits --local` attaches every commit in the depth window, including ones that never touched the app being released. This pollutes the release's commit list and suspect-commit data. Add a --path flag that scopes the local git log to one or more comma-separated subtrees via `git log <range> -- <paths>`. It implies --local, and is rejected when combined with --auto or --commit, whose commit ranges are expanded server-side where the CLI can't filter by path. Closes #1156 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
Contributor
Codecov Results 📊✅ Patch coverage is 88.24%. Project has 5111 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.48% 81.56% +0.08%
==========================================
Files 397 397 —
Lines 27702 27712 +10
Branches 17991 18013 +22
==========================================
+ Hits 22570 22601 +31
- Misses 5132 5111 -21
- Partials 1862 1866 +4Generated by Codecov Action |
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.
Summary
In a monorepo,
sentry release set-commits --localattaches every commit in the depth window to the release — including commits that never touched the app being released (backend, web, other apps). That pollutes the release's commit list and suspect-commit data.This adds a
--pathflag that scopes the local git log to one or more subtrees, so a release for one app only gets the commits that actually touched it.How it works
--pathappends a pathspec to the localgit log(git log <range> -- <paths>) ingetCommitLog. Paths are comma-separated and passed as discrete argv entries after--(no shell, so no injection).It only works in local mode, so:
--pathimplies--local— you don't need to pass both.--pathwith--autoor--commitis a hard error. Those modes hand a SHA range to Sentry, which expands it into commits server-side, so the CLI never sees per-commit file lists and can't filter them by path.--path(e.g.--path ,) errors instead of silently falling through to auto mode.--initial-depth).Path filtering for
--auto/--commitwould require a Sentry API change and is intentionally out of scope.Test plan
test/lib/git-commit-log.test.ts(new): asserts the pathspec argv (--+ paths, ordering after the range, omitted when no paths) and NUL parsing.test/commands/release/set-commits.test.ts:--pathimplies local, comma-separated paths, and the three guardrail errors.biomeclean.To try it locally in a monorepo checkout:
Closes #1156