Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/commands/react_native/appcenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: Some(&release),
dist: None,
note: None,
Expand All @@ -214,7 +214,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: Some(&release),
dist: Some(dist),
note: None,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/react_native/gradle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {

processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: Some(version),
dist: Some(dist),
note: None,
Expand All @@ -136,7 +136,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
// Debug Id Upload
processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: None,
dist: None,
note: None,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/react_native/xcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
if dist_from_env.is_err() && release_from_env.is_err() && matches.get_flag("no_auto_release") {
processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: None,
dist: None,
note: None,
Expand Down Expand Up @@ -380,7 +380,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
None => {
processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: release_name.as_deref(),
dist: dist.as_deref(),
note: None,
Expand All @@ -393,7 +393,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
for dist in dists {
processor.upload(&UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: release_name.as_deref(),
dist: Some(dist),
note: None,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sourcemaps/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
let max_wait = wait_for_secs.map_or(DEFAULT_MAX_WAIT, Duration::from_secs);
let upload_context = UploadContext {
org: &org,
projects: Some(projects.as_non_empty_slice()),
projects: projects.as_non_empty_slice(),
release: version.as_deref(),
dist: matches.get_one::<String>("dist").map(String::as_str),
note: matches.get_one::<String>("note").map(String::as_str),
Expand Down
53 changes: 12 additions & 41 deletions src/utils/file_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,19 @@ pub fn initialize_legacy_release_upload(context: &UploadContext) -> Result<()> {
// if a project is provided which is technically unnecessary for the
// legacy upload though it will unlikely to be what users want.
let chunk_options = context.chunk_upload_options;
if context.projects.is_some()
&& (chunk_options.supports(ChunkUploadCapability::ArtifactBundles)
|| chunk_options.supports(ChunkUploadCapability::ArtifactBundlesV2))
if chunk_options.supports(ChunkUploadCapability::ArtifactBundles)
|| chunk_options.supports(ChunkUploadCapability::ArtifactBundlesV2)
{
return Ok(());
}

// TODO: make this into an error later down the road
if context.projects.is_none() {
eprintln!(
"{}",
style(
"warning: no project specified. \
While this upload will succeed it will be unlikely that \
this is what you wanted. Future versions of sentry will \
require a project to be set."
)
.red()
);
}

if let Some(version) = context.release {
let api = Api::current();
api.authenticated()?.new_release(
context.org,
&NewRelease {
version: version.to_owned(),
projects: context.projects.map(Vec::from).unwrap_or_default(),
projects: context.projects.into(),
..Default::default()
},
)?;
Expand All @@ -80,7 +65,7 @@ pub fn initialize_legacy_release_upload(context: &UploadContext) -> Result<()> {
#[derive(Debug, Clone)]
pub struct UploadContext<'a> {
pub org: &'a str,
pub projects: Option<NonEmptySlice<'a, String>>,
pub projects: NonEmptySlice<'a, String>,
pub release: Option<&'a str>,
pub dist: Option<&'a str>,
pub note: Option<&'a str>,
Expand Down Expand Up @@ -185,13 +170,11 @@ impl<'a> TryFrom<&'a UploadContext<'_>> for LegacyUploadContext<'a> {
..
} = value;

let project = projects
.map(|projects| match <&[_]>::from(projects) {
[] => unreachable!("NonEmptySlice cannot be empty"),
[project] => Ok(project.as_str()),
[_, _, ..] => Err(LegacyUploadContextError::ProjectMultiple),
})
.transpose()?;
let project = Some(match <&[_]>::from(projects) {
[] => unreachable!("NonEmptySlice cannot be empty"),
[project] => Ok(project.as_str()),
[_, _, ..] => Err(LegacyUploadContextError::ProjectMultiple),
}?);

let release = release.ok_or(LegacyUploadContextError::ReleaseMissing)?;

Expand Down Expand Up @@ -536,23 +519,12 @@ fn poll_assemble(
);
}

// We fall back to legacy release upload if server lacks artifact bundle support, or if
// no projects are specified. context.projects has Some(projects) in all cases, besides
// the following:
// - For `files upload`, we can have None projects. We don't need a separate warning,
// because `files upload` is already deprecated.
// - For `debug-files bundle-jvm`, but although that codepath uses the `UploadContext`,
// it does not actually use it to perform an upload, so we never hit this codepath.
let artifact_bundle_projects = server_supports_artifact_bundles
.then_some(context.projects)
.flatten();

let response = loop {
// prefer standalone artifact bundle upload over legacy release based upload
let response = if let Some(projects) = artifact_bundle_projects {
let response = if server_supports_artifact_bundles {
authenticated_api.assemble_artifact_bundle(
context.org,
projects,
context.projects,
checksum,
chunks,
context.release,
Expand Down Expand Up @@ -642,7 +614,6 @@ fn upload_files_chunked(
if let Some(projects) = options
.supports(ChunkUploadCapability::ArtifactBundlesV2)
.then_some(context.projects)
.flatten()
{
let api = Api::current();
let response = api.authenticated()?.assemble_artifact_bundle(
Expand Down Expand Up @@ -677,7 +648,7 @@ fn print_upload_context_details(context: &UploadContext) {
println!(
"{} {}",
style("> Projects:").dim(),
style(context.projects.as_deref().unwrap_or_default().join(", ")).yellow()
style(context.projects.join(", ")).yellow()
);
println!(
"{} {}",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/source_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'a> From<&'a UploadContext<'a>> for BundleContext<'a> {
fn from(context: &'a UploadContext<'a>) -> Self {
Self {
org: context.org,
projects: context.projects,
projects: Some(context.projects),
note: context.note,
release: context.release,
dist: context.dist,
Expand Down
Loading