From dcaeaad15d2ff5c68fb7238bcf8418b9413425ba Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 23 Nov 2022 15:25:41 -0600 Subject: [PATCH] fix(vendor): Make `vendor` work similar to `package` since it resolves manifest correctly --- src/cargo/ops/cargo_package.rs | 20 +++---- src/cargo/ops/vendor.rs | 101 ++++++++++++++++++++++----------- tests/testsuite/vendor.rs | 61 ++++++++++++++++++++ 3 files changed, 139 insertions(+), 43 deletions(-) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index ae5c7558fc4c..f7b44c98de22 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -40,24 +40,24 @@ pub struct PackageOpts<'cfg> { const ORIGINAL_MANIFEST_FILE: &str = "Cargo.toml.orig"; const VCS_INFO_FILE: &str = ".cargo_vcs_info.json"; -struct ArchiveFile { +pub struct ArchiveFile { /// The relative path in the archive (not including the top-level package /// name directory). - rel_path: PathBuf, + pub rel_path: PathBuf, /// String variant of `rel_path`, for convenience. - rel_str: String, + pub rel_str: String, /// The contents to add to the archive. - contents: FileContents, + pub contents: FileContents, } -enum FileContents { +pub enum FileContents { /// Absolute path to the file on disk to add to the archive. OnDisk(PathBuf), /// Generates a file. Generated(GeneratedFile), } -enum GeneratedFile { +pub enum GeneratedFile { /// Generates `Cargo.toml` by rewriting the original. Manifest, /// Generates `Cargo.lock` in some cases (like if there is a binary). @@ -67,14 +67,14 @@ enum GeneratedFile { } #[derive(Serialize)] -struct VcsInfo { +pub struct VcsInfo { git: GitVcsInfo, /// Path to the package within repo (empty string if root). / not \ path_in_vcs: String, } #[derive(Serialize)] -struct GitVcsInfo { +pub struct GitVcsInfo { sha1: String, } @@ -219,7 +219,7 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult