-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Generate .cargo_vcs_info.json and include in cargo package
#5786
Changes from all commits
5e31236
fdd333f
ba64367
fb1bfdc
7e3cdcb
b553d72
cd21233
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,27 +175,56 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. | |
[PACKAGING] foo v0.0.1 ([..]) | ||
[ARCHIVING] [..] | ||
[ARCHIVING] [..] | ||
[ARCHIVING] .cargo_vcs_info.json | ||
", | ||
), | ||
); | ||
|
||
println!("package sub-repo"); | ||
assert_that( | ||
cargo | ||
.arg("package") | ||
.arg("-v") | ||
.arg("--no-verify") | ||
.cwd(p.root().join("a")), | ||
execs().with_status(0).with_stderr( | ||
"\ | ||
#[cfg(unix)] | ||
{ | ||
println!("package sub-repo (unix)"); | ||
assert_that( | ||
cargo | ||
.arg("package") | ||
.arg("-v") | ||
.arg("--no-verify") | ||
.cwd(p.root().join("a")), | ||
execs().with_status(0).with_stderr( | ||
"\ | ||
[WARNING] manifest has no description[..] | ||
See http://doc.crates.io/manifest.html#package-metadata for more info. | ||
[PACKAGING] a v0.0.1 ([..]) | ||
[ARCHIVING] [..] | ||
[ARCHIVING] [..] | ||
[ARCHIVING] Cargo.toml | ||
[ARCHIVING] src[/]lib.rs | ||
[ARCHIVING] .cargo_vcs_info.json | ||
", | ||
), | ||
); | ||
), | ||
); | ||
} | ||
|
||
// FIXME: From this required change in the test (omits final | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm this seems like it's a bit worrisome, do we know what changed from before to cause this test to fail on windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No we don't know that anything changed. the prior Also I've changed the order of checks (in cargo_package) vs list output, so another side-effect could be an earlier failure in a check, but that is not apparent. With the PR changes, So I'm asking to move forward with merging this, then followup with a specific test for this which can be backported if necessary for personal diagnostic purposes. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also: I have a logic flaw in the code comment, clarified above, which I'll fix. When I manually reviewed test fixtures, it looked like the sub-repo was dirty, so that makes me think this the no-git-repo-found case. |
||
// .cargo_vcs_info.json) we can only conclude that on windows, and windows | ||
// only, cargo is failing to find the parent repo | ||
#[cfg(windows)] | ||
{ | ||
println!("package sub-repo (windows)"); | ||
assert_that( | ||
cargo | ||
.arg("package") | ||
.arg("-v") | ||
.arg("--no-verify") | ||
.cwd(p.root().join("a")), | ||
execs().with_status(0).with_stderr( | ||
"\ | ||
[WARNING] manifest has no description[..] | ||
See http://doc.crates.io/manifest.html#package-metadata for more info. | ||
[PACKAGING] a v0.0.1 ([..]) | ||
[ARCHIVING] Cargo.toml | ||
[ARCHIVING] src[/]lib.rs | ||
", | ||
), | ||
); | ||
} | ||
} | ||
|
||
#[test] | ||
|
@@ -220,6 +249,42 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. | |
); | ||
} | ||
|
||
#[test] | ||
fn vcs_file_collision() { | ||
let p = project().build(); | ||
let _ = git::repo(&paths::root().join("foo")) | ||
.file( | ||
"Cargo.toml", | ||
r#" | ||
[project] | ||
name = "foo" | ||
description = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
license = "MIT" | ||
documentation = "foo" | ||
homepage = "foo" | ||
repository = "foo" | ||
exclude = ["*.no-existe"] | ||
"#) | ||
.file( | ||
"src/main.rs", | ||
r#" | ||
fn main() {} | ||
"#) | ||
.file(".cargo_vcs_info.json", "foo") | ||
.build(); | ||
assert_that( | ||
p.cargo("package").arg("--no-verify"), | ||
execs().with_status(101).with_stderr(&format!( | ||
"\ | ||
[ERROR] Invalid inclusion of reserved file name .cargo_vcs_info.json \ | ||
in package source | ||
", | ||
)), | ||
); | ||
} | ||
|
||
#[test] | ||
fn path_dependency_no_version() { | ||
let p = project() | ||
|
@@ -326,7 +391,6 @@ fn exclude() { | |
"\ | ||
[WARNING] manifest has no description[..] | ||
See http://doc.crates.io/manifest.html#package-metadata for more info. | ||
[PACKAGING] foo v0.0.1 ([..]) | ||
[WARNING] [..] file `dir_root_1[/]some_dir[/]file` WILL be excluded [..] | ||
See [..] | ||
[WARNING] [..] file `dir_root_2[/]some_dir[/]file` WILL be excluded [..] | ||
|
@@ -339,6 +403,7 @@ See [..] | |
See [..] | ||
[WARNING] [..] file `some_dir[/]file_deep_1` WILL be excluded [..] | ||
See [..] | ||
[PACKAGING] foo v0.0.1 ([..]) | ||
[ARCHIVING] [..] | ||
[ARCHIVING] [..] | ||
[ARCHIVING] [..] | ||
|
@@ -495,7 +560,7 @@ fn no_duplicates_from_modified_tracked_files() { | |
cargo.cwd(p.root()); | ||
assert_that(cargo.clone().arg("build"), execs().with_status(0)); | ||
assert_that( | ||
cargo.arg("package").arg("--list"), | ||
cargo.arg("package").arg("--list").arg("--allow-dirty"), | ||
execs().with_status(0).with_stdout( | ||
"\ | ||
Cargo.toml | ||
|
@@ -1176,6 +1241,7 @@ fn package_lockfile_git_repo() { | |
p.cargo("package").arg("-l").masquerade_as_nightly_cargo(), | ||
execs().with_status(0).with_stdout( | ||
"\ | ||
.cargo_vcs_info.json | ||
Cargo.lock | ||
Cargo.toml | ||
src/main.rs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm could you elaborate a bit on why the file locks and syncs are needed here? I was thinking we'd just synthesize this file directly into the tarball (like
Cargo.toml.orig
without actually putting it on the filesystem)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured early on that I wanted a sentry file to try and make it at least inconvenient to spoof the hash, for example by protecting against interference from another
cargo package
process. The changes would be reduced without the sentry file however. Do you think the anti-spoof efforts don't justify the increased complexity? Note: The test failure by platform diff will remain an issue even without the linked sentry file.Another early thought was that
cargo package
was doing something sentry file like, with the tarball produced being valided before being moved in place, so this was for parity.