Skip to content

Commit 9721ea0

Browse files
authored
Remove dsyms/associate API usage (#1886)
1 parent be94aa6 commit 9721ea0

File tree

5 files changed

+5
-206
lines changed

5 files changed

+5
-206
lines changed

src/api.rs

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@ use uuid::Uuid;
3939

4040
use crate::config::{Auth, Config};
4141
use crate::constants::{ARCH, EXT, PLATFORM, RELEASE_REGISTRY_LATEST_URL, VERSION};
42-
use crate::utils::android::AndroidManifest;
4342
use crate::utils::file_upload::UploadContext;
4443
use crate::utils::http::{self, is_absolute_url, parse_link_header};
4544
use crate::utils::progress::ProgressBar;
4645
use crate::utils::retry::{get_default_backoff, DurationAsMilliseconds};
4746
use crate::utils::sourcemaps::get_sourcemap_reference_from_headers;
4847
use crate::utils::ui::{capitalize_string, make_byte_progress_bar};
49-
use crate::utils::xcode::InfoPlist;
5048

5149
// Based on https://docs.rs/percent-encoding/1.0.1/src/percent_encoding/lib.rs.html#104
5250
// WHATWG Spec: https://url.spec.whatwg.org/#percent-encoded-bytes
@@ -1356,50 +1354,6 @@ impl Api {
13561354
}
13571355
}
13581356

1359-
/// Associate apple debug symbols with a build
1360-
pub fn associate_apple_dsyms(
1361-
&self,
1362-
org: &str,
1363-
project: &str,
1364-
info_plist: &InfoPlist,
1365-
checksums: Vec<String>,
1366-
) -> ApiResult<Option<AssociateDsymsResponse>> {
1367-
self.associate_dsyms(
1368-
org,
1369-
project,
1370-
&AssociateDsyms {
1371-
platform: "apple".to_string(),
1372-
checksums,
1373-
name: info_plist.name().to_string(),
1374-
app_id: info_plist.bundle_id().to_string(),
1375-
version: info_plist.version().to_string(),
1376-
build: Some(info_plist.build().to_string()),
1377-
},
1378-
)
1379-
}
1380-
1381-
/// Associate proguard mappings with an android app
1382-
pub fn associate_android_proguard_mappings(
1383-
&self,
1384-
org: &str,
1385-
project: &str,
1386-
manifest: &AndroidManifest,
1387-
checksums: Vec<String>,
1388-
) -> ApiResult<Option<AssociateDsymsResponse>> {
1389-
self.associate_dsyms(
1390-
org,
1391-
project,
1392-
&AssociateDsyms {
1393-
platform: "android".to_string(),
1394-
checksums,
1395-
name: manifest.name(),
1396-
app_id: manifest.package().to_string(),
1397-
version: manifest.version_name().to_string(),
1398-
build: Some(manifest.version_code().to_string()),
1399-
},
1400-
)
1401-
}
1402-
14031357
pub fn associate_proguard_mappings(
14041358
&self,
14051359
org: &str,
@@ -1430,39 +1384,6 @@ impl Api {
14301384
}
14311385
}
14321386

1433-
/// Associate arbitrary debug symbols with a build
1434-
pub fn associate_dsyms(
1435-
&self,
1436-
org: &str,
1437-
project: &str,
1438-
data: &AssociateDsyms,
1439-
) -> ApiResult<Option<AssociateDsymsResponse>> {
1440-
// in case we have no checksums to send up the server does not actually
1441-
// let us associate anything. This generally makes sense but means that
1442-
// from the client side we need to deal with this separately. In this
1443-
// case we just pretend we did a request that did nothing.
1444-
if data.checksums.is_empty() {
1445-
return Ok(Some(AssociateDsymsResponse {
1446-
associated_dsyms: vec![],
1447-
}));
1448-
}
1449-
1450-
let path = format!(
1451-
"/projects/{}/{}/files/dsyms/associate/",
1452-
PathArg(org),
1453-
PathArg(project)
1454-
);
1455-
let resp = self
1456-
.request(Method::Post, &path)?
1457-
.with_json_body(data)?
1458-
.send()?;
1459-
if resp.status() == 404 {
1460-
Ok(None)
1461-
} else {
1462-
resp.convert()
1463-
}
1464-
}
1465-
14661387
/// Triggers reprocessing for a project
14671388
pub fn trigger_reprocessing(&self, org: &str, project: &str) -> ApiResult<bool> {
14681389
let path = format!(
@@ -2486,17 +2407,6 @@ impl DebugInfoFile {
24862407
}
24872408
}
24882409

2489-
#[derive(Debug, Serialize)]
2490-
pub struct AssociateDsyms {
2491-
pub platform: String,
2492-
pub checksums: Vec<String>,
2493-
pub name: String,
2494-
#[serde(rename = "appId")]
2495-
pub app_id: String,
2496-
pub version: String,
2497-
pub build: Option<String>,
2498-
}
2499-
25002410
#[derive(Debug, Serialize)]
25012411
pub struct AssociateProguard {
25022412
pub release_name: String,
@@ -2585,12 +2495,6 @@ impl IssueFilter {
25852495
}
25862496
}
25872497

2588-
#[derive(Deserialize)]
2589-
pub struct AssociateDsymsResponse {
2590-
#[serde(rename = "associatedDsymFiles")]
2591-
pub associated_dsyms: Vec<DebugInfoFile>,
2592-
}
2593-
25942498
#[derive(Deserialize, Debug)]
25952499
pub struct Organization {
25962500
pub id: String,

src/commands/debug_files/upload.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::constants::DEFAULT_MAX_WAIT;
1616
use crate::utils::args::ArgExt;
1717
use crate::utils::dif::{DifType, ObjectDifFeatures};
1818
use crate::utils::dif_upload::{DifFormat, DifUpload};
19-
use crate::utils::progress::{ProgressBar, ProgressStyle};
2019
use crate::utils::system::QuietExit;
2120
use crate::utils::xcode::{InfoPlist, MayDetach};
2221

@@ -304,7 +303,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
304303
}
305304

306305
// Try to resolve the Info.plist either by path or from Xcode
307-
let info_plist = match matches.get_one::<String>("info_plist") {
306+
// TODO: maybe remove this completely?
307+
let _info_plist = match matches.get_one::<String>("info_plist") {
308308
Some(path) => Some(InfoPlist::from_path(path)?),
309309
None => InfoPlist::discover_from_env()?,
310310
};
@@ -324,35 +324,6 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
324324
let (uploaded, has_processing_errors) = upload.upload()?;
325325
let api = Api::current();
326326

327-
// Associate the dSYMs with the Info.plist data, if available
328-
if let Some(ref info_plist) = info_plist {
329-
let progress_style = ProgressStyle::default_spinner()
330-
.template("{spinner} Associating dSYMs with {msg}...");
331-
332-
let pb = ProgressBar::new_spinner();
333-
pb.enable_steady_tick(100);
334-
pb.set_style(progress_style);
335-
pb.set_message(&info_plist.to_string());
336-
337-
let checksums = uploaded.iter().map(|dif| dif.checksum.clone()).collect();
338-
let response = api.associate_apple_dsyms(&org, &project, info_plist, checksums)?;
339-
pb.finish_and_clear();
340-
341-
if let Some(association) = response {
342-
if association.associated_dsyms.is_empty() {
343-
println!("{} No new debug symbols to associate.", style(">").dim());
344-
} else {
345-
println!(
346-
"{} Associated {} debug symbols with the build.",
347-
style(">").dim(),
348-
style(association.associated_dsyms.len()).yellow()
349-
);
350-
}
351-
} else {
352-
info!("Server does not support dSYM associations. Ignoring.");
353-
}
354-
}
355-
356327
// Trigger reprocessing only if requested by user
357328
if matches.get_flag("no_reprocessing") {
358329
println!("{} skipped reprocessing", style(">").dim());

src/commands/upload_proguard.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use uuid::Uuid;
1414
use crate::api::Api;
1515
use crate::api::AssociateProguard;
1616
use crate::config::Config;
17-
use crate::utils::android::{dump_proguard_uuids_as_properties, AndroidManifest};
17+
use crate::utils::android::dump_proguard_uuids_as_properties;
1818
use crate::utils::args::ArgExt;
1919
use crate::utils::fs::{get_sha1_checksum, TempFile};
2020
use crate::utils::system::QuietExit;
@@ -106,6 +106,7 @@ pub fn make_command(command: Command) -> Command {
106106
.long("android-manifest")
107107
.value_name("PATH")
108108
.conflicts_with("app_id")
109+
.hide(true)
109110
.help("Read version and version code from an Android manifest file."),
110111
)
111112
.arg(
@@ -152,12 +153,6 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
152153
let mut mappings = vec![];
153154
let mut all_checksums = vec![];
154155

155-
let android_manifest = if let Some(path) = matches.get_one::<String>("android_manifest") {
156-
Some(AndroidManifest::from_path(path)?)
157-
} else {
158-
None
159-
};
160-
161156
let forced_uuid = matches.get_one::<Uuid>("uuid");
162157
if forced_uuid.is_some() && paths.len() != 1 {
163158
bail!(
@@ -261,12 +256,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
261256
}
262257
}
263258

264-
// update the uuids
265-
if let Some(android_manifest) = android_manifest {
266-
api.associate_android_proguard_mappings(&org, &project, &android_manifest, all_checksums)?;
267-
268259
// if values are given associate
269-
} else if let Some(app_id) = matches.get_one::<String>("app_id") {
260+
if let Some(app_id) = matches.get_one::<String>("app_id") {
270261
let version = matches.get_one::<String>("version").unwrap().to_owned();
271262
let build: Option<String> = matches.get_one::<String>("version_code").cloned();
272263

src/utils/android.rs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,12 @@
11
use std::collections::HashMap;
2-
use std::fmt;
32
use std::fs;
43
use std::io;
54
use std::path::Path;
65

76
use anyhow::{format_err, Result};
8-
use elementtree::Element;
97
use itertools::Itertools;
108
use uuid::Uuid;
119

12-
pub struct AndroidManifest {
13-
root: Element,
14-
}
15-
16-
const ANDROID_NS: &str = "http://schemas.android.com/apk/res/android";
17-
18-
impl AndroidManifest {
19-
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<AndroidManifest> {
20-
let f = fs::File::open(path.as_ref())?;
21-
let root = Element::from_reader(f)?;
22-
Ok(AndroidManifest { root })
23-
}
24-
25-
/// Returns the package ID
26-
pub fn package(&self) -> &str {
27-
self.root.get_attr("package").unwrap_or("unknown")
28-
}
29-
30-
/// Returns a name
31-
pub fn name(&self) -> String {
32-
// fallback name is the package reformatted
33-
self.root
34-
.get_attr("package")
35-
.unwrap_or("unknown")
36-
.rsplit('.')
37-
.next()
38-
.unwrap()
39-
.chars()
40-
.enumerate()
41-
.map(|(idx, c)| {
42-
if idx == 0 {
43-
c.to_uppercase().to_string()
44-
} else {
45-
c.to_lowercase().to_string()
46-
}
47-
})
48-
.collect()
49-
}
50-
51-
/// Returns the internal version code for this manifest
52-
pub fn version_code(&self) -> &str {
53-
self.root
54-
.get_attr((ANDROID_NS, "versionCode"))
55-
.unwrap_or("0")
56-
}
57-
58-
/// Returns the human readable version number of the manifest
59-
pub fn version_name(&self) -> &str {
60-
self.root
61-
.get_attr((ANDROID_NS, "versionName"))
62-
.unwrap_or("0.0")
63-
}
64-
}
65-
66-
impl fmt::Debug for AndroidManifest {
67-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
68-
f.debug_struct("AndroidManifest")
69-
.field("package", &self.package())
70-
.field("version_code", &self.version_code())
71-
.field("version_name", &self.version_name())
72-
.finish()
73-
}
74-
}
75-
7610
pub fn dump_proguard_uuids_as_properties<P: AsRef<Path>>(p: P, uuids: &[Uuid]) -> Result<()> {
7711
let mut props = match fs::File::open(p.as_ref()) {
7812
Ok(f) => java_properties::read(f).unwrap_or_else(|_| HashMap::new()),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Options:
3737
upload (this also automatically disables reprocessing). This
3838
is useful if you just want to verify the mapping files and
3939
write the proguard UUIDs into a properties file.
40-
--android-manifest <PATH> Read version and version code from an Android manifest file.
4140
--write-properties <PATH> Write the UUIDs for the processed mapping files into the given
4241
properties file.
4342
--require-one Requires at least one file to upload or the command will error.

0 commit comments

Comments
 (0)