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

vendor: implement --versioned-dirs #7631

Merged
merged 5 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert --explicit-version -> --versioned-dirs
  • Loading branch information
jsgf committed Dec 6, 2019
commit fd80795503237caa3458db02098b990be3198e96
7 changes: 3 additions & 4 deletions src/bin/cargo/commands/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ pub fn cli() -> App {
.multiple(true),
)
.arg(
Arg::with_name("explicit-version")
.short("-x")
.long("explicit-version")
Arg::with_name("versioned-dirs")
.long("versioned-dirs")
.help("Always include version in subdir name"),
)
.arg(
Expand Down Expand Up @@ -114,7 +113,7 @@ https://github.com/rust-lang/cargo/issues/new
&ops::VendorOptions {
no_delete: args.is_present("no-delete"),
destination: &path,
explicit_version: args.is_present("explicit-version"),
versioned_dirs: args.is_present("versioned-dirs"),
extra: args
.values_of_os("tomls")
.unwrap_or_default()
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::path::{Path, PathBuf};

pub struct VendorOptions<'a> {
pub no_delete: bool,
pub explicit_version: bool,
pub versioned_dirs: bool,
pub destination: &'a Path,
pub extra: Vec<PathBuf>,
}
Expand Down Expand Up @@ -187,7 +187,7 @@ fn sync(
.parent()
.expect("manifest_path should point to a file");
let max_version = *versions[&id.name()].iter().rev().next().unwrap().0;
let dir_has_version_suffix = opts.explicit_version || id.version() != max_version;
let dir_has_version_suffix = opts.versioned_dirs || id.version() != max_version;
let dst_name = if dir_has_version_suffix {
// Eg vendor/futures-0.1.13
format!("{}-{}", id.name(), id.version())
Expand Down
4 changes: 2 additions & 2 deletions src/etc/man/cargo-vendor.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ Don\(cqt delete the "vendor" directory when vendoring, but rather keep all
existing contents of the vendor directory.
.RE
.sp
\fB\-\-explicit\-version\fP
\fB\-\-versioned\-dirs\fP
.RS 4
Normally versions are only added to disambiguate multiple versions of the same package.
This option causes all directories in the "vendor" directory to be explicitly versioned,
This option causes all directories in the "vendor" directory to be versioned,
which makes it easier to track the history of vendored packages over time, and can help
with the performance of re-vendoring when only a subset of the packages have changed.
.RE
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn two_explicit_versions() {
Package::new("bitflags", "0.7.0").publish();
Package::new("bitflags", "0.8.0").publish();

p.cargo("vendor --respect-source-config --explicit-version")
p.cargo("vendor --respect-source-config --versioned-dirs")
.run();

let lock = p.read_file("vendor/bitflags-0.8.0/Cargo.toml");
Expand Down