From f42ed7a86339f662ba385d82b65422e52fdb947b Mon Sep 17 00:00:00 2001 From: bors Date: Tue, 28 Apr 2020 20:24:08 +0000 Subject: [PATCH] Auto merge of #8175 - ehuss:allow-package-list, r=alexcrichton Allow `cargo package --list` even for things that don't package. `cargo package --list` was changed in #7905 to generate `Cargo.lock` earlier. If there is a problem, then it would fail where previously it would succeed. This changes it so that file generation is deferred until after `--list`. This also changes it so that the "dependencies must have a version" check is deferred until after `--list` as well. Closes #8151 --- src/cargo/ops/cargo_package.rs | 32 +++++++++++------ tests/testsuite/package.rs | 55 +++++++++++++++++++++++++++-- tests/testsuite/publish_lockfile.rs | 4 +-- tests/testsuite/registry.rs | 15 +++++--- 4 files changed, 86 insertions(+), 20 deletions(-) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index cda35913aa9..d16d98c9e6a 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -50,8 +50,17 @@ struct ArchiveFile { enum FileContents { /// Absolute path to the file on disk to add to the archive. OnDisk(PathBuf), - /// Contents of a file generated in memory. - Generated(String), + /// Generates a file. + Generated(GeneratedFile), +} + +enum GeneratedFile { + /// Generates `Cargo.toml` by rewriting the original. + Manifest, + /// Generates `Cargo.lock` in some cases (like if there is a binary). + Lockfile, + /// Adds a `.cargo-vcs_info.json` file if in a (clean) git repo. + VcsInfo(String), } pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult> { @@ -71,8 +80,6 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult