Skip to content

Commit eb9eef4

Browse files
committed
Show mobile-app upload show analysis URL
1 parent 5f9403e commit eb9eef4

File tree

2 files changed

+49
-28
lines changed

2 files changed

+49
-28
lines changed

src/api/data_types/chunking/mobile_app.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ pub struct AssembleMobileAppResponse {
2020
pub state: ChunkedFileState,
2121
pub missing_chunks: Vec<Digest>,
2222
pub detail: Option<String>,
23+
pub artifact_id: Option<String>,
2324
}

src/commands/mobile_app/upload.rs

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use symbolic::common::ByteView;
1616
use zip::write::SimpleFileOptions;
1717
use zip::{DateTime, ZipWriter};
1818

19-
use crate::api::{Api, AuthenticatedApi, ChunkUploadCapability};
19+
use crate::api::{Api, AssembleMobileAppResponse, AuthenticatedApi, ChunkUploadCapability};
2020
use crate::config::Config;
2121
use crate::utils::args::ArgExt as _;
2222
use crate::utils::chunks::{upload_chunks, Chunk, ASSEMBLE_POLL_INTERVAL};
@@ -129,9 +129,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
129129

130130
let config = Config::current();
131131
let (org, project) = config.get_org_and_project(matches)?;
132+
let base_url = config.get_base_url()?;
132133

133-
let mut uploaded_paths = vec![];
134-
let mut errored_paths = vec![];
134+
let mut uploaded_paths_and_ids = vec![];
135+
let mut errored_paths_and_reasons = vec![];
135136
for (path, zip) in normalized_zips {
136137
info!("Uploading file: {}", path.display());
137138
let bytes = ByteView::open(zip.path())?;
@@ -143,41 +144,56 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
143144
sha.as_deref(),
144145
build_configuration,
145146
) {
146-
Ok(_) => {
147+
Ok(artifact_id) => {
147148
info!("Successfully uploaded file: {}", path.display());
148-
uploaded_paths.push(path.to_path_buf());
149+
uploaded_paths_and_ids.push((path.to_path_buf(), artifact_id));
149150
}
150151
Err(e) => {
151152
debug!("Failed to upload file at path {}: {}", path.display(), e);
152-
errored_paths.push(path.to_path_buf());
153+
errored_paths_and_reasons.push((path.to_path_buf(), e));
153154
}
154155
}
155156
}
156157

157-
if !errored_paths.is_empty() {
158+
if !errored_paths_and_reasons.is_empty() {
158159
warn!(
159160
"Failed to upload {} file{}:",
160-
errored_paths.len(),
161-
if errored_paths.len() == 1 { "" } else { "s" }
161+
errored_paths_and_reasons.len(),
162+
if errored_paths_and_reasons.len() == 1 {
163+
""
164+
} else {
165+
"s"
166+
}
162167
);
163-
for path in errored_paths {
164-
warn!(" - {}", path.display());
168+
for (path, reason) in errored_paths_and_reasons {
169+
warn!(" - {} ({})", path.display(), reason);
165170
}
166171
}
167172

168-
println!(
169-
"Successfully uploaded {} file{} to Sentry",
170-
uploaded_paths.len(),
171-
if uploaded_paths.len() == 1 { "" } else { "s" }
172-
);
173-
if uploaded_paths.len() < 3 {
174-
for path in &uploaded_paths {
175-
println!(" - {}", path.display());
176-
}
177-
}
178-
179-
if uploaded_paths.is_empty() {
173+
if uploaded_paths_and_ids.is_empty() {
180174
bail!("Failed to upload any files");
175+
} else {
176+
println!(
177+
"Successfully uploaded {} file{} to Sentry",
178+
uploaded_paths_and_ids.len(),
179+
if uploaded_paths_and_ids.len() == 1 {
180+
""
181+
} else {
182+
"s"
183+
}
184+
);
185+
if uploaded_paths_and_ids.len() < 3 {
186+
for (path, artifact_id) in &uploaded_paths_and_ids {
187+
let url = format!(
188+
"{}/{}/preprod/{}/{}",
189+
base_url,
190+
org,
191+
project,
192+
artifact_id
193+
);
194+
println!(" - {} {}", path.display(), url);
195+
}
196+
}
181197
}
182198
Ok(())
183199
}
@@ -337,14 +353,15 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
337353
Ok(temp_file)
338354
}
339355

356+
/// Returns artifact id if upload was successful.
340357
fn upload_file(
341358
api: &AuthenticatedApi,
342359
bytes: &[u8],
343360
org: &str,
344361
project: &str,
345362
sha: Option<&str>,
346363
build_configuration: Option<&str>,
347-
) -> Result<()> {
364+
) -> Result<String> {
348365
const SELF_HOSTED_ERROR_HINT: &str = "If you are using a self-hosted Sentry server, \
349366
update to the latest version of Sentry to use the mobile-app upload command.";
350367

@@ -400,7 +417,7 @@ fn upload_file(
400417
println!("Nothing to upload, all files are on the server");
401418
}
402419

403-
poll_assemble(
420+
let response = poll_assemble(
404421
api,
405422
checksum,
406423
&checksums,
@@ -409,7 +426,10 @@ fn upload_file(
409426
sha,
410427
build_configuration,
411428
)?;
412-
Ok(())
429+
430+
response
431+
.artifact_id
432+
.ok_or(anyhow!("Missing artifactId in response"))
413433
}
414434

415435
fn poll_assemble(
@@ -420,7 +440,7 @@ fn poll_assemble(
420440
project: &str,
421441
sha: Option<&str>,
422442
build_configuration: Option<&str>,
423-
) -> Result<()> {
443+
) -> Result<AssembleMobileAppResponse> {
424444
debug!("Polling assemble for checksum: {}", checksum);
425445

426446
let progress_style = ProgressStyle::default_spinner().template("{spinner} Processing files...");
@@ -453,7 +473,7 @@ fn poll_assemble(
453473
info!("File processing complete");
454474
}
455475

456-
Ok(())
476+
Ok(response)
457477
}
458478

459479
#[cfg(not(windows))]

0 commit comments

Comments
 (0)