Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- (snapshots) Add `--selective` flag to `build snapshots` to indicate the upload contains only a subset of images ([#3268](https://github.com/getsentry/sentry-cli/pull/3268))
- (bundle-jvm) Allow running directly on a project root (including multi-module repos) by automatically collecting only JVM source files (`.java`, `.kt`, `.scala`, `.groovy`), respecting `.gitignore`, and excluding common build output directories ([#3260](https://github.com/getsentry/sentry-cli/pull/3260))
- (bundle-jvm) Add `--exclude` option for custom glob patterns to exclude files/directories from source collection ([#3260](https://github.com/getsentry/sentry-cli/pull/3260))

Expand Down
43 changes: 43 additions & 0 deletions src/api/data_types/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub struct SnapshotsManifest<'a> {
/// is greater than this value (e.g. 0.01 = only report changes >= 1%).
#[serde(skip_serializing_if = "Option::is_none")]
pub diff_threshold: Option<f64>,
/// When true, this upload contains only a subset of images.
/// Removals and renames will not be detected on PRs.
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub selective: bool,
#[serde(flatten)]
pub vcs_info: VcsInfo<'a>,
}
Expand Down Expand Up @@ -59,6 +63,45 @@ mod tests {

use serde_json::json;

fn empty_vcs_info() -> VcsInfo<'static> {
VcsInfo {
head_sha: None,
base_sha: None,
vcs_provider: "".into(),
head_repo_name: "".into(),
base_repo_name: "".into(),
head_ref: "".into(),
base_ref: "".into(),
pr_number: None,
}
}

#[test]
fn manifest_omits_selective_when_false() {
let manifest = SnapshotsManifest {
app_id: "app".into(),
images: HashMap::new(),
diff_threshold: None,
selective: false,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
assert!(!json.as_object().unwrap().contains_key("selective"));
}

#[test]
fn manifest_includes_selective_when_true() {
let manifest = SnapshotsManifest {
app_id: "app".into(),
images: HashMap::new(),
diff_threshold: None,
selective: true,
vcs_info: empty_vcs_info(),
};
let json = serde_json::to_value(&manifest).unwrap();
assert_eq!(json["selective"], json!(true));
}

#[test]
fn cli_managed_fields_override_sidecar_fields() {
let extra = serde_json::from_value(json!({
Expand Down
12 changes: 12 additions & 0 deletions src/commands/build/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ pub fn make_command(command: Command) -> Command {
Example: 0.01 = only report image changes >= 1%.",
),
)
.arg(
Arg::new("selective")
.long("selective")
.action(clap::ArgAction::SetTrue)
.help(
"Indicates this upload contains only a subset of images. \
Removals and renames cannot be detected on PRs.",
),
)
.git_metadata_args()
}

Expand Down Expand Up @@ -142,10 +151,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
// Build manifest from discovered images
let diff_threshold = matches.get_one::<f64>("diff_threshold").copied();

let selective = matches.get_flag("selective");

let manifest = SnapshotsManifest {
app_id: app_id.clone(),
images: manifest_entries,
diff_threshold,
selective,
vcs_info,
};

Expand Down
12 changes: 8 additions & 4 deletions tests/integration/_cases/build/build-snapshots-help.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ Options:
--log-level <LOG_LEVEL>
Set the log output verbosity. [possible values: trace, debug, info, warn, error]

--head-sha <head_sha>
The VCS commit sha to use for the upload. If not provided, the current commit sha will be
used.

--quiet
Do not print any output while preserving correct exit code. This flag is currently
implemented only for selected subcommands.

[aliases: --silent]

--selective
Indicates this upload contains only a subset of images. Removals and renames cannot be
detected on PRs.

--head-sha <head_sha>
The VCS commit sha to use for the upload. If not provided, the current commit sha will be
used.

--base-sha <base_sha>
The VCS commit's base sha to use for the upload. If not provided, the merge-base of the
current and remote branch will be used.
Expand Down
Loading