Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 `--all-image-names` flag to `build snapshots` to accept a file listing all expected preview names (newline or comma-delimited). Images in the list but not uploaded are reported as 'skipped' instead of 'removed' ([#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
4 changes: 4 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>,
/// Full list of expected preview names. When provided, images in this list
/// but absent from the upload are reported as "skipped" instead of "removed".
#[serde(skip_serializing_if = "Option::is_none")]
pub all_image_names: Option<Vec<String>>,
#[serde(flatten)]
pub vcs_info: VcsInfo<'a>,
}
Expand Down
56 changes: 56 additions & 0 deletions src/commands/build/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ pub fn make_command(command: Command) -> Command {
Example: 0.01 = only report image changes >= 1%.",
),
)
.arg(
Arg::new("all_image_names")
.long("all-image-names")
.value_name("PATH")
.help(
"Path to a file containing the full list of preview names \
(one per line, comma-separated, or both). When provided, \
only images in the upload directory are compared; missing \
images listed here are reported as 'skipped' rather than \
'removed'.",
),
)
.git_metadata_args()
}

Expand Down Expand Up @@ -129,6 +141,49 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

validate_image_sizes(&images)?;

let all_image_names = matches
.get_one::<String>("all_image_names")
.map(|path| -> Result<Vec<String>> {
let content = std::fs::read_to_string(path)
.with_context(|| format!("Failed to read all-image-names file: {path}"))?;
Ok(content
.lines()
.flat_map(|l| l.split(','))
.map(str::trim)
.filter(|s| !s.is_empty())
.map(String::from)
.collect())
})
.transpose()?;

if let Some(ref names) = all_image_names {
if names.is_empty() {
anyhow::bail!("--all-image-names file is empty or contains no names");
}
let names_set: std::collections::HashSet<&str> = names.iter().map(String::as_str).collect();
let missing: Vec<String> = images
.iter()
.filter_map(|img| {
let name = img
.relative_path
.file_name()?
.to_string_lossy()
.into_owned();
if names_set.contains(name.as_str()) {
None
} else {
Some(name)
}
})
.collect();
if !missing.is_empty() {
anyhow::bail!(
"These uploaded images are not listed in --all-image-names: {}",
missing.join(", ")
);
}
}

// Upload image files to objectstore
println!(
"{} Uploading {} image {}",
Expand All @@ -146,6 +201,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
app_id: app_id.clone(),
images: manifest_entries,
diff_threshold,
all_image_names,
vcs_info,
};

Expand Down
11 changes: 8 additions & 3 deletions tests/integration/_cases/build/build-snapshots-help.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@ 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.
--all-image-names <PATH>
Copy link
Copy Markdown
Member

@rbro112 rbro112 Apr 15, 2026

Choose a reason for hiding this comment

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

I'd elaborate on what a "missing" image is and what this list does to clarify this more. Maybe "Path to a file containing a list of preview names (...). Sentry will use this list to determine what images to diff. Any image in this list will be diffed against the base. Images not uploaded, but present in this list will be marked as 'skipped' rather than 'removed'."

Copy link
Copy Markdown
Member

@rbro112 rbro112 Apr 15, 2026

Choose a reason for hiding this comment

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

Also name suggestions: --all-snapshot-file-names or --all-image-file-names, or --diffable-image-file-names

Copy link
Copy Markdown
Contributor Author

@NicoHinderling NicoHinderling Apr 15, 2026

Choose a reason for hiding this comment

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

switched to all-image-file-names (in addition to adding the new "selective" flag)

Path to a file containing the full list of preview names (one per line, comma-separated,
or both). When provided, only images in the upload directory are compared; missing images
listed here are reported as 'skipped' rather than 'removed'.

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

[aliases: --silent]

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