Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(release): make set-commits --clear actually clear commits - #1196

Merged
betegon merged 1 commit into
mainfrom
fix/release-set-commits-clear
Jul 3, 2026
Merged

betegon merged 1 commit into
mainfrom
fix/release-set-commits-clear

Conversation

@betegon

@betegon betegon commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

sentry release set-commits <version> --clear reported success but left the commits attached in Sentry. This makes --clear actually remove them.

Reported in the last comment of #1156 (against the nightly build): "sentry release set-commits org/version --clear doesn't seem to work."

What changed

--clear used to send { commits: [] } via updateRelease. But the Sentry release PUT endpoint (organization_release_details.py) only runs release.clear_commits() when it receives an explicitly-empty refs array — an empty commits list is falsy server-side and hits no branch, so it silently no-ops:

commit_list = result.get("commits")
if commit_list:            # [] is falsy -> skipped
    release.set_commits(commit_list)

refs = result.get("refs")
if not refs:
    ...
    else:
        if result.get("refs") == []:   # only True when refs:[] is sent
            release.clear_commits()

Now --clear routes through the existing setCommitsWithRefs(org, version, []), which sends { refs: [] } and triggers clear_commits(). This also drops the now-unused updateRelease import from the command.

Test plan

  • pnpm vitest run test/commands/release/set-commits.test.ts — 15 pass (1 new: asserts --clear calls setCommitsWithRefs with an empty refs array).
  • Lint + biome clean on both touched files.

Made with Cursor

--clear sent `{ commits: [] }`, but the Sentry release PUT endpoint only
runs `clear_commits()` when it receives an explicitly-empty `refs` array;
an empty `commits` list is falsy server-side and silently no-ops. Route
--clear through setCommitsWithRefs(org, version, []) so it sends
`{ refs: [] }` and the commits are removed.

Reported in #1156.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jul 3, 2026

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-1196/

Built to branch gh-pages at 2026-07-03 16:01 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@betegon
betegon marked this pull request as ready for review July 3, 2026 16:01
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5302 uncovered lines.
✅ Project coverage is 81.84%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.77%    81.84%    +0.07%
==========================================
  Files          423       423         —
  Lines        29194     29194         —
  Branches     18980     18980         —
==========================================
+ Hits         23871     23892       +21
- Misses        5323      5302       -21
- Partials      1969      1974        +5

Generated by Codecov Action

@betegon
betegon merged commit c58dc83 into main Jul 3, 2026
31 checks passed
@betegon
betegon deleted the fix/release-set-commits-clear branch July 3, 2026 16:09
betegon added a commit that referenced this pull request Jul 6, 2026
## Summary

Adds a `--from <ref>` flag to `sentry release set-commits` so monorepo
users can associate only the commits that changed a given subtree since
the last release — the use case raised in the last comment of #1156:

```
sentry release set-commits 1.0.0 --from v0.9.0 --path apps/mobile,apps/shared
```

This reads the local `v0.9.0..HEAD` range, keeps only commits touching
those paths, and sends them.

## Why a new flag instead of `--commit PREV..SHA --path ...`

Path filtering can only happen client-side. `--commit`/`--auto` send a
ref range that Sentry expands **server-side**, and the API has no
concept of paths (confirmed in `set_refs`/`set_commits` on the backend)
— so a path filter there would be silently ignored. That's why `--path`
already implies local git, and why the range it needs must also be
local. `--from` reuses the existing `getCommitLog(from, paths)` path
(`git log <ref>..HEAD -- <paths>`).

## What changed

- **`--from <ref>`** (implies `--local`): reads `<ref>..HEAD` from local
git. Combines with `--path`. Cannot be combined with `--auto`/`--commit`
(same rule as `--path`), and rejects an empty ref.
- **Depth handling**: a `from..HEAD` range is self-bounding, so
`--initial-depth` is dropped when `--from` is set. `getCommitLog` now
only adds `--max-count` for a positive depth (omitting it reads the
whole range).
- Extracted `parseCommitRefs` and `parseLocalScope` helpers to keep
`func` under the cognitive-complexity limit.
- Requires a full (non-shallow) checkout spanning the range — already
surfaced via the existing shallow-clone warning.

## Test plan

- `pnpm vitest run test/commands/release/set-commits.test.ts
test/lib/git-commit-log.test.ts` — 28 pass (new: `--from` implies local,
combines with `--path`, rejects empty/`--auto`/`--commit`;
`getCommitLog` omits `--max-count` for a range and applies it for a
positive depth).
- `pnpm tsc --noEmit`, biome, and `pnpm run check:fragments` all clean.

Follow-up to #1156 (the `--clear` fix landed in #1196).

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant