Skip to content

feat(release): filter set-commits by path for monorepos (CLI-339)#1159

Merged
betegon merged 2 commits into
mainfrom
feat/release-set-commits-path
Jun 29, 2026
Merged

feat(release): filter set-commits by path for monorepos (CLI-339)#1159
betegon merged 2 commits into
mainfrom
feat/release-set-commits-path

Conversation

@betegon

@betegon betegon commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

In a monorepo, sentry release set-commits --local attaches 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 --path flag 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.

sentry release set-commits mobile@1.4.0 --path apps/mobile,packages/shared-ui

How it works

--path appends a pathspec to the local git log (git log <range> -- <paths>) in getCommitLog. Paths are comma-separated and passed as discrete argv entries after -- (no shell, so no injection).

It only works in local mode, so:

  • --path implies --local — you don't need to pass both.
  • --path with --auto or --commit is 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.
  • Empty/whitespace-only --path (e.g. --path ,) errors instead of silently falling through to auto mode.
  • If no commits match the paths within the depth window, it warns (likely a typo'd path or too-shallow --initial-depth).

Path filtering for --auto/--commit would 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: --path implies local, comma-separated paths, and the three guardrail errors.
  • All green; biome clean.

To try it locally in a monorepo checkout:

sentry release set-commits app@test --path apps/mobile   # implies local, scoped commits
git log --max-count=20 -- apps/mobile                     # cross-check the same set

Closes #1156

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>
@linear-code

linear-code Bot commented Jun 29, 2026

Copy link
Copy Markdown

CLI-339

@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1159/

Built to branch gh-pages at 2026-06-29 13:06 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 88.24%. Project has 5111 uncovered lines.
✅ Project coverage is 81.56%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/commands/release/set-commits.ts 86.67% ⚠️ 2 Missing and 1 partials
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        +4

Generated by Codecov Action

@betegon betegon marked this pull request as ready for review June 29, 2026 13:33
@github-actions github-actions Bot added the risk: high PR risk score: high label Jun 29, 2026
@betegon betegon merged commit b34a052 into main Jun 29, 2026
31 checks passed
@betegon betegon deleted the feat/release-set-commits-path branch June 29, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support path/subdirectory filtering in releases set-commits for monorepo setups

1 participant