Skip to content

Commit 01959df

Browse files
feat(proguard): Add UUID command for mapping files
Add `sentry-cli proguard uuid <PATH>` to compute and print the UUID for a single ProGuard mapping file. The command reuses existing `ByteView` loading and `ProguardMapping::try_from` validation, so success output remains only the UUID plus a newline while missing files or invalid mappings exit non-zero. Update the `proguard` command registration and help snapshots, and add integration coverage for help output, successful UUID computation, missing files, and invalid mappings. This keeps behavior explicit and aligned with [issue #3173](#3173) without changing upload flows. Closes #3173 Closes [CLI-297](https://linear.app/getsentry/issue/CLI-297/expose-command-to-obtain-compute-uuid-for-proguard-mapping)
1 parent da65c19 commit 01959df

File tree

10 files changed

+93
-0
lines changed

10 files changed

+93
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Improvements
66

77
- Moved `sentry-cli upload-proguard` to `sentry-cli proguard upload`, aligning the API with similar upload commands like `debug-files upload` and `sourcemaps upload` ([#3174](https://github.com/getsentry/sentry-cli/pull/3174)). `sentry-cli upload-proguard` remains supported as an alias, so no migration is required.
8+
- Added `sentry-cli proguard uuid <PATH>` to compute and print the UUID for a ProGuard mapping file ([#3176](https://github.com/getsentry/sentry-cli/pull/3176)).
89

910
## 3.2.3
1011

src/commands/proguard/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ use anyhow::Result;
22
use clap::{ArgMatches, Command};
33

44
pub mod upload;
5+
pub mod uuid;
56

67
macro_rules! each_subcommand {
78
($mac:ident) => {
89
$mac!(upload);
10+
$mac!(uuid);
911
};
1012
}
1113

src/commands/proguard/uuid.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use anyhow::{Context as _, Result};
2+
use clap::{Arg, ArgMatches, Command};
3+
use symbolic::common::ByteView;
4+
5+
use crate::utils::proguard::ProguardMapping;
6+
7+
pub fn make_command(command: Command) -> Command {
8+
command
9+
.about("Compute the UUID for a ProGuard mapping file.")
10+
.arg(
11+
Arg::new("path")
12+
.value_name("PATH")
13+
.help("The path to the mapping file.")
14+
.required(true),
15+
)
16+
}
17+
18+
pub fn execute(matches: &ArgMatches) -> Result<()> {
19+
let path = matches
20+
.get_one::<String>("path")
21+
.expect("required argument");
22+
23+
let byteview = ByteView::open(path)
24+
.with_context(|| format!("failed to open proguard mapping '{path}'"))?;
25+
let mapping = ProguardMapping::try_from(byteview)
26+
.with_context(|| format!("failed to parse proguard mapping '{path}'"))?;
27+
28+
println!("{}", mapping.uuid());
29+
Ok(())
30+
}

tests/integration/_cases/proguard/proguard-help.trycmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Usage: sentry-cli[EXE] proguard [OPTIONS] <COMMAND>
77

88
Commands:
99
upload Upload ProGuard mapping files to a project.
10+
uuid Compute the UUID for a ProGuard mapping file.
1011
help Print this message or the help of the given subcommand(s)
1112

1213
Options:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
```
2+
$ sentry-cli proguard uuid --help
3+
? success
4+
Compute the UUID for a ProGuard mapping file.
5+
6+
Usage: sentry-cli[EXE] proguard uuid [OPTIONS] <PATH>
7+
8+
Arguments:
9+
<PATH> The path to the mapping file.
10+
11+
Options:
12+
--header <KEY:VALUE> Custom headers that should be attached to all requests
13+
in key:value format.
14+
--auth-token <AUTH_TOKEN> Use the given Sentry auth token.
15+
--log-level <LOG_LEVEL> Set the log output verbosity. [possible values: trace, debug, info,
16+
warn, error]
17+
--quiet Do not print any output while preserving correct exit code. This
18+
flag is currently implemented only for selected subcommands.
19+
[aliases: --silent]
20+
-h, --help Print help
21+
22+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```
2+
$ sentry-cli proguard uuid tests/integration/_fixtures/proguard.txt
3+
? failed
4+
error: failed to parse proguard mapping 'tests/integration/_fixtures/proguard.txt'
5+
6+
Caused by:
7+
Proguard mapping does not contain line information
8+
9+
Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
10+
Please attach the full debug log to all bug reports.
11+
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```
2+
$ sentry-cli proguard uuid tests/integration/_fixtures/proguard/upload/does-not-exist.txt
3+
? failed
4+
error: failed to open proguard mapping 'tests/integration/_fixtures/proguard/upload/does-not-exist.txt'
5+
6+
Caused by:
7+
No such file or directory (os error 2)
8+
9+
Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
10+
Please attach the full debug log to all bug reports.
11+
12+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```
2+
$ sentry-cli proguard uuid tests/integration/_fixtures/proguard/upload/mapping.txt
3+
? success
4+
c038584d-c366-570c-ad1e-034fa0d194d7
5+
6+
```

tests/integration/proguard/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
mod upload;
2+
mod uuid;

tests/integration/proguard/uuid.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use crate::integration::TestManager;
2+
3+
#[test]
4+
fn command_proguard_uuid() {
5+
TestManager::new().register_trycmd_test("proguard/proguard-uuid*.trycmd");
6+
}

0 commit comments

Comments
 (0)