Skip to content

Commit b8c061f

Browse files
runningcodeclaude
andauthored
fix(build): Skip base_sha and base_ref when equal to head_sha during auto-inference (EME-607) (#2924)
## Summary This PR modifies `sentry-cli` to skip setting `base_sha` and `base_ref` when they are auto-inferred and `base_sha` equals `head_sha`. ## Changes - Added tracking to distinguish between user-provided CLI arguments and auto-inferred values for `base_sha` and `base_ref` - When both values are auto-inferred and `base_sha == head_sha`, we now set both to `None` before sending to the API - User-provided values via `--base-sha` and `--base-ref` are always respected regardless of their values ## Rationale When `base_sha` equals `head_sha`, there is no meaningful comparison baseline since we'd be comparing a commit against itself. This typically occurs in certain CI scenarios where the auto-inference logic cannot determine a proper base commit. By skipping these values, we allow the backend to handle the comparison more appropriately. Closes EME-607 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <[email protected]>
1 parent b9f99c1 commit b8c061f

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- The `sentry-cli debug-files bundle-jvm` no longer makes any HTTP requests to Sentry, meaning auth tokens are no longer needed, and the command can be run offline ([#2926](https://github.com/getsentry/sentry-cli/pull/2926)).
88

9+
### Fixes
10+
11+
- Skip setting `base_sha` and `base_ref` when they equal `head_sha` during auto-inference, since comparing a commit to itself provides no meaningful baseline ([#2924](https://github.com/getsentry/sentry-cli/pull/2924)).
12+
913
## 2.58.0
1014

1115
### New Features

src/commands/build/upload.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,12 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
230230
base_repo_name,
231231
)
232232
};
233-
let base_sha = matches
233+
234+
// Track whether base_sha and base_ref were explicitly provided by the user
235+
let base_sha_from_user = matches.get_one::<String>("base_sha").is_some();
236+
let base_ref_from_user = matches.get_one::<String>("base_ref").is_some();
237+
238+
let mut base_sha = matches
234239
.get_one("base_sha")
235240
.map(String::as_str)
236241
.map(Cow::Borrowed)
@@ -241,6 +246,24 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
241246
.flatten()
242247
.map(Cow::Owned)
243248
});
249+
250+
let mut base_ref = base_ref;
251+
252+
// If base_sha equals head_sha and both were auto-inferred, skip setting base_sha and base_ref
253+
// but keep head_sha (since comparing a commit to itself provides no meaningful baseline)
254+
if !base_sha_from_user
255+
&& !base_ref_from_user
256+
&& base_sha.is_some()
257+
&& head_sha.is_some()
258+
&& base_sha.as_deref() == head_sha.as_deref()
259+
{
260+
debug!(
261+
"Base SHA equals head SHA ({}), and both were auto-inferred. Skipping base_sha and base_ref, but keeping head_sha.",
262+
base_sha.as_deref().expect("base_sha is Some at this point")
263+
);
264+
base_sha = None;
265+
base_ref = None;
266+
}
244267
let pr_number = matches
245268
.get_one("pr_number")
246269
.copied()

0 commit comments

Comments
 (0)