mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
cargo package: Change lock file updates from warning to requiring -v.
This commit is contained in:
parent
eae89007a6
commit
6eb55abe2c
@ -9,11 +9,12 @@ use flate2::{Compression, GzBuilder};
|
||||
use log::debug;
|
||||
use serde_json::{self, json};
|
||||
use tar::{Builder, EntryType, Header};
|
||||
use termcolor::Color;
|
||||
|
||||
use crate::core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor};
|
||||
use crate::core::resolver::Method;
|
||||
use crate::core::{
|
||||
Package, PackageId, PackageIdSpec, PackageSet, Resolve, Source, SourceId, Workspace,
|
||||
Package, PackageId, PackageIdSpec, PackageSet, Resolve, Source, SourceId, Verbosity, Workspace,
|
||||
};
|
||||
use crate::ops;
|
||||
use crate::sources::PathSource;
|
||||
@ -465,6 +466,9 @@ fn compare_resolve(
|
||||
orig_resolve: &Resolve,
|
||||
new_resolve: &Resolve,
|
||||
) -> CargoResult<()> {
|
||||
if config.shell().verbosity() != Verbosity::Verbose {
|
||||
return Ok(());
|
||||
}
|
||||
let new_set: BTreeSet<PackageId> = new_resolve.iter().collect();
|
||||
let orig_set: BTreeSet<PackageId> = orig_resolve.iter().collect();
|
||||
let added = new_set.difference(&orig_set);
|
||||
@ -533,9 +537,8 @@ fn compare_resolve(
|
||||
)
|
||||
}
|
||||
};
|
||||
config
|
||||
.shell()
|
||||
.warn(format!("package `{}` added to Cargo.lock{}", pkg_id, extra))?;
|
||||
let msg = format!("package `{}` added to Cargo.lock{}", pkg_id, extra);
|
||||
config.shell().status_with_color("Note", msg, Color::Cyan)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ fn lock_file_and_workspace() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn warn_resolve_changes() {
|
||||
fn note_resolve_changes() {
|
||||
// `multi` has multiple sources (path and registry).
|
||||
Package::new("mutli", "0.1.0").publish();
|
||||
// `updated` is always from registry, but should not change.
|
||||
@ -178,14 +178,16 @@ fn warn_resolve_changes() {
|
||||
// Make sure this does not change or warn.
|
||||
Package::new("updated", "1.0.1").publish();
|
||||
|
||||
p.cargo("package --no-verify")
|
||||
p.cargo("package --no-verify -v --allow-dirty")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr_unordered(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([..])
|
||||
[ARCHIVING] Cargo.toml
|
||||
[ARCHIVING] src/main.rs
|
||||
[UPDATING] `[..]` index
|
||||
[WARNING] package `mutli v0.1.0` added to Cargo.lock, was originally sourced from `[..]/foo/mutli`
|
||||
[WARNING] package `patched v1.0.0` added to Cargo.lock, was originally sourced from `[..]/foo/patched`
|
||||
[NOTE] package `mutli v0.1.0` added to Cargo.lock, was originally sourced from `[..]/foo/mutli`
|
||||
[NOTE] package `patched v1.0.0` added to Cargo.lock, was originally sourced from `[..]/foo/patched`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -267,7 +269,7 @@ fn no_warn_workspace_extras() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn out_of_date_lock_warn() {
|
||||
fn out_of_date_lock_note() {
|
||||
// Dependency is force-changed from an out-of-date Cargo.lock.
|
||||
Package::new("dep", "1.0.0").publish();
|
||||
Package::new("dep", "2.0.0").publish();
|
||||
@ -300,13 +302,15 @@ fn out_of_date_lock_warn() {
|
||||
"#,
|
||||
),
|
||||
);
|
||||
p.cargo("package --no-verify")
|
||||
p.cargo("package --no-verify -v --allow-dirty")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([..])
|
||||
[ARCHIVING] Cargo.toml
|
||||
[ARCHIVING] src/main.rs
|
||||
[UPDATING] `[..]` index
|
||||
[WARNING] package `dep v2.0.0` added to Cargo.lock, previous version was `1.0.0`
|
||||
[NOTE] package `dep v2.0.0` added to Cargo.lock, previous version was `1.0.0`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
@ -1620,6 +1620,7 @@ fn substitute_macros(input: &str) -> String {
|
||||
("[IGNORED]", " Ignored"),
|
||||
("[INSTALLED]", " Installed"),
|
||||
("[REPLACED]", " Replaced"),
|
||||
("[NOTE]", " Note"),
|
||||
];
|
||||
let mut result = input.to_owned();
|
||||
for &(pat, subst) in ¯os {
|
||||
|
Loading…
x
Reference in New Issue
Block a user