Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d0c6e74
fix partial sha & add tests
srest2021 Sep 9, 2025
eeadf4f
update tests
srest2021 Sep 9, 2025
501e432
linter
srest2021 Sep 9, 2025
2355ec6
linter
srest2021 Sep 9, 2025
cdd97cc
make git test consistent with other tests
srest2021 Sep 9, 2025
713678c
move git test out of mod
srest2021 Sep 9, 2025
b662ada
use find_matching_rev
srest2021 Sep 9, 2025
04df02d
preserve partial sha when sending to api
srest2021 Sep 10, 2025
6dad2ac
linter
srest2021 Sep 10, 2025
fd030f2
rename
srest2021 Sep 10, 2025
651c7c2
clean up comments
srest2021 Sep 10, 2025
e5983dc
fix logic & tests
srest2021 Sep 10, 2025
43830ac
fix test
srest2021 Sep 10, 2025
7c165ff
linter
srest2021 Sep 10, 2025
898af8a
Merge branch 'master' into srest2021/REPLAY-413
szokeasaurusrex Sep 11, 2025
6cc111f
only valid full & partial SHAs accepted
srest2021 Sep 12, 2025
8b900ad
Merge branch 'master' into srest2021/REPLAY-413
srest2021 Sep 12, 2025
acf91a5
revert prior changes
srest2021 Sep 12, 2025
40b1f39
linteR
srest2021 Sep 12, 2025
9859a9c
Update src/commands/releases/set_commits.rs
srest2021 Sep 15, 2025
85d334c
soft validation
srest2021 Sep 15, 2025
8ddca69
linter
srest2021 Sep 15, 2025
6ecf8b0
Merge branch 'master' into srest2021/REPLAY-413
srest2021 Sep 15, 2025
116ce99
update validaton & help
srest2021 Sep 17, 2025
2c4f96e
Update src/commands/releases/set_commits.rs
srest2021 Sep 17, 2025
4dd3548
Update src/commands/releases/set_commits.rs
srest2021 Sep 17, 2025
6d3fa1c
add 64 char constant
srest2021 Sep 17, 2025
c515e78
Update src/constants.rs
srest2021 Sep 18, 2025
307ed46
Make the example SHA have hex chars only
srest2021 Sep 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 49 additions & 32 deletions src/commands/releases/set_commits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use clap::{Arg, ArgAction, ArgMatches, Command};
use lazy_static::lazy_static;
use regex::Regex;

use crate::api::{Api, NewRelease, NoneReleaseInfo, OptionalReleaseInfo, UpdatedRelease};
use crate::api::{Api, NewRelease, NoneReleaseInfo, OptionalReleaseInfo, Ref, UpdatedRelease};
use crate::config::Config;
use crate::constants::MAX_COMMIT_SHA_LENGTH;
use crate::utils::args::ArgExt as _;
use crate::utils::formatting::Table;
use crate::utils::vcs::{
Expand Down Expand Up @@ -53,19 +54,16 @@ pub fn make_command(command: Command) -> Command {
.short('c')
.value_name("SPEC")
.action(ArgAction::Append)
.help("Defines a single commit for a repo as \
.help(format!("Defines a single commit for a repo as \
identified by the repo name in the remote Sentry config. \
If no commit has been specified sentry-cli will attempt \
to auto discover that repository in the local git repo \
and then use the HEAD commit. This will either use the \
current git repository or attempt to auto discover a \
submodule with a compatible URL.\n\n\
The value can be provided as `REPO` in which case sentry-cli \
will auto-discover the commit based on reachable repositories. \
Alternatively it can be provided as `REPO#PATH` in which case \
the current commit of the repository at the given PATH is \
assumed. To override the revision `@REV` can be appended \
which will force the revision to a certain value."))
The value must be provided as `REPO@SHA` where SHA is \
at most {MAX_COMMIT_SHA_LENGTH} characters. To specify a range, use `REPO@PREV_SHA..SHA` \
format.\n\n\
Note: You must specify a previous commit when setting commits for the first release.\n\n\
Examples:\
\n - `my-repo@abc123` (partial SHA)\
\n - `my-repo@62aaca3ed186edc7671b4cca0ab6ec53cb7de8b5` (full SHA)\
\n - `my-repo@abc123..def456` (commit range)")))
// Legacy flag that has no effect, left hidden for backward compatibility
.arg(Arg::new("ignore-empty")
.long("ignore-empty")
Expand All @@ -83,14 +81,14 @@ fn strip_sha(sha: &str) -> &str {
sha
}
}

pub fn execute(matches: &ArgMatches) -> Result<()> {
let config = Config::current();
let api = Api::current();
let authenticated_api = api.authenticated()?;
let version = matches.get_one::<String>("version").unwrap();
let org = config.get_org(matches)?;
let repos = authenticated_api.list_organization_repos(&org)?;
let mut commit_specs = vec![];

let heads = if repos.is_empty() {
None
Expand All @@ -105,30 +103,49 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
Some(vec![])
} else if matches.get_flag("local") {
None
} else {
if let Some(commits) = matches.get_many::<String>("commits") {
for spec in commits {
let commit_spec = CommitSpec::parse(spec)?;
if repos
.iter()
.any(|r| r.name.to_lowercase() == commit_spec.repo.to_lowercase())
{
commit_specs.push(commit_spec);
} else {
bail!("Unknown repo '{}'", commit_spec.repo);
} else if let Some(commits) = matches.get_many::<String>("commits") {
let mut refs = vec![];
for spec in commits {
let commit_spec = CommitSpec::parse(spec)?;

if !repos
.iter()
.any(|r| r.name.to_lowercase() == commit_spec.repo.to_lowercase())
{
bail!("Unknown repo '{}'", commit_spec.repo);
}

if commit_spec.rev.len() > MAX_COMMIT_SHA_LENGTH {
bail!(
"Invalid commit SHA '{}'. Commit SHAs must be {} characters or less.",
commit_spec.rev,
MAX_COMMIT_SHA_LENGTH
);
}

if let Some(ref prev_rev) = commit_spec.prev_rev {
if prev_rev.len() > MAX_COMMIT_SHA_LENGTH {
bail!(
"Invalid previous commit SHA '{}'. Commit SHAs must be {} characters or less.",
prev_rev,
MAX_COMMIT_SHA_LENGTH
);
}
}

refs.push(Ref {
repo: commit_spec.repo,
rev: commit_spec.rev,
prev_rev: commit_spec.prev_rev,
});
}
let commits = find_heads(
Some(commit_specs),
&repos,
Some(config.get_cached_vcs_remote()),
)?;
if commits.is_empty() {
if refs.is_empty() {
None
} else {
Some(commits)
Some(refs)
}
} else {
None
Copy link

Choose a reason for hiding this comment

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

Bug: Command Change Breaks Implicit Commit Discovery

The set_commits command now bypasses auto-discovery when no --commit arguments are provided. Previously, find_heads() would still be called, allowing implicit commit discovery. This change may break existing workflows that relied on that behavior.

Fix in Cursor Fix in Web

};

// make sure the release exists if projects are given
Expand Down
2 changes: 2 additions & 0 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ pub const DEFAULT_MAX_DIF_ITEM_SIZE: u64 = 1024 * 1024; // 1MB
pub const DEFAULT_MAX_DIF_UPLOAD_SIZE: u64 = 35 * 1024 * 1024; // 35MB
/// Default maximum time to wait for file assembly.
pub const DEFAULT_MAX_WAIT: Duration = Duration::from_secs(5 * 60);
/// Maximum length for commit SHA values, enforced in backend.
pub const MAX_COMMIT_SHA_LENGTH: usize = 64;

include!(concat!(env!("OUT_DIR"), "/constants.gen.rs"));