Skip to content

Commit 6eb55ab

Browse files
committed
cargo package: Change lock file updates from warning to requiring -v.
1 parent eae8900 commit 6eb55ab

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/cargo/ops/cargo_package.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ use flate2::{Compression, GzBuilder};
99
use log::debug;
1010
use serde_json::{self, json};
1111
use tar::{Builder, EntryType, Header};
12+
use termcolor::Color;
1213

1314
use crate::core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor};
1415
use crate::core::resolver::Method;
1516
use crate::core::{
16-
Package, PackageId, PackageIdSpec, PackageSet, Resolve, Source, SourceId, Workspace,
17+
Package, PackageId, PackageIdSpec, PackageSet, Resolve, Source, SourceId, Verbosity, Workspace,
1718
};
1819
use crate::ops;
1920
use crate::sources::PathSource;
@@ -465,6 +466,9 @@ fn compare_resolve(
465466
orig_resolve: &Resolve,
466467
new_resolve: &Resolve,
467468
) -> CargoResult<()> {
469+
if config.shell().verbosity() != Verbosity::Verbose {
470+
return Ok(());
471+
}
468472
let new_set: BTreeSet<PackageId> = new_resolve.iter().collect();
469473
let orig_set: BTreeSet<PackageId> = orig_resolve.iter().collect();
470474
let added = new_set.difference(&orig_set);
@@ -533,9 +537,8 @@ fn compare_resolve(
533537
)
534538
}
535539
};
536-
config
537-
.shell()
538-
.warn(format!("package `{}` added to Cargo.lock{}", pkg_id, extra))?;
540+
let msg = format!("package `{}` added to Cargo.lock{}", pkg_id, extra);
541+
config.shell().status_with_color("Note", msg, Color::Cyan)?;
539542
}
540543
Ok(())
541544
}

tests/testsuite/publish_lockfile.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ fn lock_file_and_workspace() {
139139
}
140140

141141
#[test]
142-
fn warn_resolve_changes() {
142+
fn note_resolve_changes() {
143143
// `multi` has multiple sources (path and registry).
144144
Package::new("mutli", "0.1.0").publish();
145145
// `updated` is always from registry, but should not change.
@@ -178,14 +178,16 @@ fn warn_resolve_changes() {
178178
// Make sure this does not change or warn.
179179
Package::new("updated", "1.0.1").publish();
180180

181-
p.cargo("package --no-verify")
181+
p.cargo("package --no-verify -v --allow-dirty")
182182
.masquerade_as_nightly_cargo()
183183
.with_stderr_unordered(
184184
"\
185185
[PACKAGING] foo v0.0.1 ([..])
186+
[ARCHIVING] Cargo.toml
187+
[ARCHIVING] src/main.rs
186188
[UPDATING] `[..]` index
187-
[WARNING] package `mutli v0.1.0` added to Cargo.lock, was originally sourced from `[..]/foo/mutli`
188-
[WARNING] package `patched v1.0.0` added to Cargo.lock, was originally sourced from `[..]/foo/patched`
189+
[NOTE] package `mutli v0.1.0` added to Cargo.lock, was originally sourced from `[..]/foo/mutli`
190+
[NOTE] package `patched v1.0.0` added to Cargo.lock, was originally sourced from `[..]/foo/patched`
189191
",
190192
)
191193
.run();
@@ -267,7 +269,7 @@ fn no_warn_workspace_extras() {
267269
}
268270

269271
#[test]
270-
fn out_of_date_lock_warn() {
272+
fn out_of_date_lock_note() {
271273
// Dependency is force-changed from an out-of-date Cargo.lock.
272274
Package::new("dep", "1.0.0").publish();
273275
Package::new("dep", "2.0.0").publish();
@@ -300,13 +302,15 @@ fn out_of_date_lock_warn() {
300302
"#,
301303
),
302304
);
303-
p.cargo("package --no-verify")
305+
p.cargo("package --no-verify -v --allow-dirty")
304306
.masquerade_as_nightly_cargo()
305307
.with_stderr(
306308
"\
307309
[PACKAGING] foo v0.0.1 ([..])
310+
[ARCHIVING] Cargo.toml
311+
[ARCHIVING] src/main.rs
308312
[UPDATING] `[..]` index
309-
[WARNING] package `dep v2.0.0` added to Cargo.lock, previous version was `1.0.0`
313+
[NOTE] package `dep v2.0.0` added to Cargo.lock, previous version was `1.0.0`
310314
",
311315
)
312316
.run();

tests/testsuite/support/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,7 @@ fn substitute_macros(input: &str) -> String {
16201620
("[IGNORED]", " Ignored"),
16211621
("[INSTALLED]", " Installed"),
16221622
("[REPLACED]", " Replaced"),
1623+
("[NOTE]", " Note"),
16231624
];
16241625
let mut result = input.to_owned();
16251626
for &(pat, subst) in &macros {

0 commit comments

Comments
 (0)