Skip to content

Commit

Permalink
Add an --ignore-yanked option
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Jan 23, 2019
1 parent 56cbbec commit 1c087ee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ fn execute_subcommand(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
&args.value_of("color").map(|s| s.to_string()),
args.is_present("frozen"),
args.is_present("locked"),
args.is_present("ignore-yanked"),
arg_target_dir,
&args
.values_of_lossy("unstable-features")
Expand Down Expand Up @@ -229,6 +230,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
)
.arg(opt("frozen", "Require Cargo.lock and cache are up to date").global(true))
.arg(opt("locked", "Require Cargo.lock is up to date").global(true))
.arg(opt("ignore-yanked", "Treat yanked crates as if they weren't yanked").global(true))
.arg(
Arg::with_name("unstable-features")
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
Expand Down
3 changes: 2 additions & 1 deletion src/cargo/sources/registry/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,11 @@ impl<'cfg> RegistryIndex<'cfg> {
) -> CargoResult<()> {
let source_id = self.source_id;
let name = dep.package_name().as_str();
let ignore_yanked = self.config.ignore_yanked();
let summaries = self.summaries(name, load)?;
let summaries = summaries
.iter()
.filter(|&&(_, yanked)| dep.source_id().precise().is_some() || !yanked)
.filter(|&&(_, yanked)| dep.source_id().precise().is_some() || !yanked || ignore_yanked)
.map(|s| s.0.clone());

// Handle `cargo update --precise` here. If specified, our own source
Expand Down
9 changes: 9 additions & 0 deletions src/cargo/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub struct Config {
frozen: bool,
/// `locked` is set if we should not update lock files
locked: bool,
/// Treat yanked crates as if they weren't yanked
ignore_yanked: bool,
/// A global static IPC control mechanism (used for managing parallel builds)
jobserver: Option<jobserver::Client>,
/// Cli flags of the form "-Z something"
Expand Down Expand Up @@ -115,6 +117,7 @@ impl Config {
extra_verbose: false,
frozen: false,
locked: false,
ignore_yanked: false,
jobserver: unsafe {
if GLOBAL_JOBSERVER.is_null() {
None
Expand Down Expand Up @@ -548,6 +551,7 @@ impl Config {
color: &Option<String>,
frozen: bool,
locked: bool,
ignore_yanked: bool,
target_dir: &Option<PathBuf>,
unstable_flags: &[String],
) -> CargoResult<()> {
Expand Down Expand Up @@ -592,6 +596,7 @@ impl Config {
self.extra_verbose = extra_verbose;
self.frozen = frozen;
self.locked = locked;
self.ignore_yanked = ignore_yanked;
self.target_dir = cli_target_dir;
self.cli_flags.parse(unstable_flags)?;

Expand All @@ -618,6 +623,10 @@ impl Config {
!self.frozen && !self.locked
}

pub fn ignore_yanked(&self) -> bool {
self.ignore_yanked
}

/// Loads configuration from the filesystem
pub fn load_values(&self) -> CargoResult<HashMap<String, ConfigValue>> {
self.load_values_from(&self.cwd)
Expand Down

0 comments on commit 1c087ee

Please sign in to comment.