Skip to content

Commit

Permalink
fix: Revert clap-rs v4 update and add regression test for 'releases f…
Browse files Browse the repository at this point in the history
…iles upload-sourcemap' (#1496)
  • Loading branch information
vaind committed Mar 2, 2023
1 parent dc6760d commit 27901b8
Show file tree
Hide file tree
Showing 77 changed files with 1,296 additions and 1,254 deletions.
19 changes: 15 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ brotli2 = "0.3.2"
bytecount = "0.6.3"
chardet = "0.2.4"
chrono = { version = "0.4.23", features = ["serde"] }
clap = { version = "4.1.6", default-features = false, features = [
clap = { version = "3.2.23", default-features = false, features = [
"std",
"suggestions",
"wrap_help",
"string",
"help",
"usage",
"error-context"
] }
console = "0.15.5"
curl = { version = "0.4.44", features = ["static-curl", "static-ssl"] }
Expand Down
2 changes: 1 addition & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ impl IssueFilter {
}

pub fn get_filter_from_matches(matches: &ArgMatches) -> Result<IssueFilter> {
if matches.get_flag("all") {
if matches.contains_id("all") {
return Ok(IssueFilter::All);
}
if let Some(status) = matches.get_one::<String>("status") {
Expand Down
19 changes: 7 additions & 12 deletions src/commands/bash_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::io::{BufRead, BufReader};
use std::path::Path;

use anyhow::Result;
use clap::{builder::ArgPredicate, Arg, ArgAction, ArgMatches, Command};
use clap::Command;
use clap::{Arg, ArgMatches};
use lazy_static::lazy_static;
use regex::Regex;
use sentry::protocol::{Event, Exception, Frame, Stacktrace, User, Value};
Expand All @@ -30,13 +31,11 @@ pub fn make_command(command: Command) -> Command {
.arg(
Arg::new("no_exit")
.long("no-exit")
.action(ArgAction::SetTrue)
.help("Do not turn on -e (exit immediately) flag automatically"),
)
.arg(
Arg::new("no_environ")
.long("no-environ")
.action(ArgAction::SetTrue)
.help("Do not send environment variables along"),
)
.arg(
Expand All @@ -48,11 +47,7 @@ pub fn make_command(command: Command) -> Command {
.arg(
Arg::new("send_event")
.long("send-event")
.action(ArgAction::SetTrue)
.requires_ifs([
(ArgPredicate::IsPresent, "traceback"),
(ArgPredicate::IsPresent, "log"),
])
.requires_all(&["traceback", "log"])
.hide(true),
)
.arg(
Expand Down Expand Up @@ -176,11 +171,11 @@ fn send_event(traceback: &str, logfile: &str, environ: bool) -> Result<()> {
}

pub fn execute(matches: &ArgMatches) -> Result<()> {
if matches.get_flag("send_event") {
if matches.contains_id("send_event") {
return send_event(
matches.get_one::<String>("traceback").unwrap(),
matches.get_one::<String>("log").unwrap(),
!matches.get_flag("no_environ"),
!matches.contains_id("no_environ"),
);
}

Expand Down Expand Up @@ -208,13 +203,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
.as_str(),
);

if matches.get_flag("no_environ") {
if matches.contains_id("no_environ") {
script = script.replace("___SENTRY_NO_ENVIRON___", "--no-environ");
} else {
script = script.replace("___SENTRY_NO_ENVIRON___", "");
}

if !matches.get_flag("no_exit") {
if !matches.contains_id("no_exit") {
script.insert_str(0, "set -e\n\n");
}
println!("{script}");
Expand Down
2 changes: 1 addition & 1 deletion src/commands/debug_files/bundle_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn make_command(command: Command) -> Command {
.arg(
Arg::new("paths")
.required(true)
.num_args(1..)
.multiple_values(true)
.action(ArgAction::Append)
.help("The path to the input debug info files."),
)
Expand Down
7 changes: 3 additions & 4 deletions src/commands/debug_files/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::io;
use std::path::Path;

use anyhow::Result;
use clap::{builder::PossibleValuesParser, Arg, ArgAction, ArgMatches, Command};
use clap::{builder::PossibleValuesParser, Arg, ArgMatches, Command};
use console::style;

use crate::utils::dif::{DifFile, DifType};
Expand Down Expand Up @@ -35,7 +35,6 @@ pub fn make_command(command: Command) -> Command {
.arg(
Arg::new("json")
.long("json")
.action(ArgAction::SetTrue)
.help("Format outputs as JSON."),
)
}
Expand All @@ -49,12 +48,12 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
.map(|t| t.parse().unwrap());
let dif = DifFile::open_path(path, ty)?;

if matches.get_flag("json") {
if matches.contains_id("json") {
serde_json::to_writer_pretty(&mut io::stdout(), &dif)?;
println!();
}

if matches.get_flag("json") || is_quiet_mode() {
if matches.contains_id("json") || is_quiet_mode() {
return if dif.is_usable() {
Ok(())
} else {
Expand Down
11 changes: 4 additions & 7 deletions src/commands/debug_files/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn make_command(command: Command) -> Command {
.value_name("ID")
.help("The debug identifiers of the files to search for.")
.value_parser(DebugId::from_str)
.num_args(1..)
.multiple_values(true)
.action(ArgAction::Append),
)
.arg(
Expand All @@ -58,13 +58,11 @@ pub fn make_command(command: Command) -> Command {
.arg(
Arg::new("no_well_known")
.long("no-well-known")
.action(ArgAction::SetTrue)
.help("Do not look for debug symbols in well known locations."),
)
.arg(
Arg::new("no_cwd")
.long("no-cwd")
.action(ArgAction::SetTrue)
.help("Do not look for debug symbols in the current working directory."),
)
.arg(
Expand All @@ -78,7 +76,6 @@ pub fn make_command(command: Command) -> Command {
.arg(
Arg::new("json")
.long("json")
.action(ArgAction::SetTrue)
.help("Format outputs as JSON."),
)
}
Expand Down Expand Up @@ -342,8 +339,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
types.extend(DifType::all());
}

let with_well_known = !matches.get_flag("no_well_known");
let with_cwd = !matches.get_flag("no_cwd");
let with_well_known = !matches.contains_id("no_well_known");
let with_cwd = !matches.contains_id("no_cwd");

// start adding well known locations
if_chain! {
Expand Down Expand Up @@ -381,7 +378,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
return Ok(());
}

if !find_ids(&paths, &types, &ids, matches.get_flag("json"))? {
if !find_ids(&paths, &types, &ids, matches.contains_id("json"))? {
return Err(QuietExit(1).into());
}

Expand Down

0 comments on commit 27901b8

Please sign in to comment.