Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish-lockfile: Various updates #6840

Merged
merged 12 commits into from
Apr 18, 2019
Prev Previous commit
Next Next commit
cargo package: Change lock file updates from warning to requiring -v.
  • Loading branch information
ehuss committed Apr 16, 2019
commit 6eb55abe2c28c4d7fda334e782215c06a1e59e4c
11 changes: 7 additions & 4 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(())
}
Expand Down
18 changes: 11 additions & 7 deletions tests/testsuite/publish_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 &macros {
Expand Down