From 7d202307cebba894a2c95e9a16b9f8e31b7501f2 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 17 Apr 2019 14:06:05 -0700 Subject: [PATCH] Include Cargo.lock in package checks. This includes `Cargo.lock` in the git dirty check. It explicitly excludes `Cargo.lock` as an untracked file, since it is not relevant for the dirty check; it is only checked if it is committed to git. This also adds `Cargo.lock` to the "did anything modify this" check during verification. I don't see a reason to exclude it (particularly since ephemeral workspaces do not save the lock file). Also add "Archiving: Cargo.lock" to the verbose output. --- src/cargo/core/package.rs | 6 ++++++ src/cargo/ops/cargo_package.rs | 28 ++++++++++++++++------------ src/cargo/sources/path.rs | 25 ++++++++++++++++--------- tests/testsuite/publish_lockfile.rs | 18 ++++++++++++++++++ 4 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 389a5ab93ec..d5f7d89fafc 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -236,6 +236,12 @@ impl Package { toml )) } + + /// Returns if package should include `Cargo.lock`. + pub fn include_lockfile(&self) -> bool { + self.manifest().publish_lockfile() + && self.targets().iter().any(|t| t.is_example() || t.is_bin()) + } } impl fmt::Display for Package { diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 937afd735fb..edb7aca9cbd 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -79,7 +79,8 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult