mirror of
https://github.com/rust-lang/cargo
synced 2024-09-13 04:51:31 +00:00
Support path_in_vcs as part of cargo_vcs_metadata
This commit is contained in:
parent
6b6b0b486d
commit
b8b127a870
|
@ -66,6 +66,8 @@ enum GeneratedFile {
|
|||
#[derive(Serialize)]
|
||||
struct VcsInfo {
|
||||
git: GitVcsInfo,
|
||||
/// Path to the package within repo (empty string if root). / not \
|
||||
path_in_vcs: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -408,8 +410,14 @@ fn check_repo_state(
|
|||
"found (git) Cargo.toml at {:?} in workdir {:?}",
|
||||
path, workdir
|
||||
);
|
||||
let path_in_vcs = path
|
||||
.parent()
|
||||
.and_then(|p| p.to_str())
|
||||
.unwrap_or("")
|
||||
.replace("\\", "/");
|
||||
return Ok(Some(VcsInfo {
|
||||
git: git(p, src_files, &repo)?,
|
||||
path_in_vcs,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,22 @@ fields in the manifest.
|
|||
See [the reference](../reference/publishing.html) for more details about
|
||||
packaging and publishing.
|
||||
|
||||
### .cargo_vcs_info.json format
|
||||
|
||||
Will generate a `.cargo_vcs_info.json` in the following format
|
||||
|
||||
```javascript
|
||||
{
|
||||
"git": {
|
||||
"sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
```
|
||||
|
||||
`path_in_vcs` will be set to a repo-relative path for packages
|
||||
in subdirectories of the version control repository.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
### Package Options
|
||||
|
|
|
@ -45,6 +45,19 @@ DESCRIPTION
|
|||
<https://doc.rust-lang.org/cargo/reference/publishing.html> for more
|
||||
details about packaging and publishing.
|
||||
|
||||
.cargo_vcs_info.json format
|
||||
Will generate a .cargo_vcs_info.json in the following format
|
||||
|
||||
{
|
||||
"git": {
|
||||
"sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
|
||||
path_in_vcs will be set to a repo-relative path for packages in
|
||||
subdirectories of the version control repository.
|
||||
|
||||
OPTIONS
|
||||
Package Options
|
||||
-l, --list
|
||||
|
|
|
@ -43,6 +43,22 @@ fields in the manifest.
|
|||
See [the reference](../reference/publishing.html) for more details about
|
||||
packaging and publishing.
|
||||
|
||||
### .cargo_vcs_info.json format
|
||||
|
||||
Will generate a `.cargo_vcs_info.json` in the following format
|
||||
|
||||
```javascript
|
||||
{
|
||||
"git": {
|
||||
"sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
```
|
||||
|
||||
`path_in_vcs` will be set to a repo-relative path for packages
|
||||
in subdirectories of the version control repository.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
### Package Options
|
||||
|
|
|
@ -67,6 +67,22 @@ fields in the manifest.
|
|||
.sp
|
||||
See \fIthe reference\fR <https://doc.rust\-lang.org/cargo/reference/publishing.html> for more details about
|
||||
packaging and publishing.
|
||||
.SS ".cargo_vcs_info.json format"
|
||||
Will generate a \fB\&.cargo_vcs_info.json\fR in the following format
|
||||
.sp
|
||||
.RS 4
|
||||
.nf
|
||||
{
|
||||
"git": {
|
||||
"sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
.fi
|
||||
.RE
|
||||
.sp
|
||||
\fBpath_in_vcs\fR will be set to a repo\-relative path for packages
|
||||
in subdirectories of the version control repository.
|
||||
.SH "OPTIONS"
|
||||
.SS "Package Options"
|
||||
.sp
|
||||
|
|
|
@ -140,8 +140,8 @@ fn package_verbose() {
|
|||
let repo = git::repo(&root)
|
||||
.file("Cargo.toml", &basic_manifest("foo", "0.0.1"))
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("a/Cargo.toml", &basic_manifest("a", "0.0.1"))
|
||||
.file("a/src/lib.rs", "")
|
||||
.file("a/a/Cargo.toml", &basic_manifest("a", "0.0.1"))
|
||||
.file("a/a/src/lib.rs", "")
|
||||
.build();
|
||||
cargo_process("build").cwd(repo.root()).run();
|
||||
|
||||
|
@ -167,7 +167,8 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
|
|||
r#"{{
|
||||
"git": {{
|
||||
"sha1": "{}"
|
||||
}}
|
||||
}},
|
||||
"path_in_vcs": ""
|
||||
}}
|
||||
"#,
|
||||
repo.revparse_head()
|
||||
|
@ -187,7 +188,7 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
|
|||
|
||||
println!("package sub-repo");
|
||||
cargo_process("package -v --no-verify")
|
||||
.cwd(repo.root().join("a"))
|
||||
.cwd(repo.root().join("a/a"))
|
||||
.with_stderr(
|
||||
"\
|
||||
[WARNING] manifest has no description[..]
|
||||
|
@ -200,6 +201,29 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
|
|||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&repo.root().join("a/a/target/package/a-0.0.1.crate")).unwrap();
|
||||
let vcs_contents = format!(
|
||||
r#"{{
|
||||
"git": {{
|
||||
"sha1": "{}"
|
||||
}},
|
||||
"path_in_vcs": "a/a"
|
||||
}}
|
||||
"#,
|
||||
repo.revparse_head()
|
||||
);
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"a-0.0.1.crate",
|
||||
&[
|
||||
"Cargo.toml",
|
||||
"Cargo.toml.orig",
|
||||
"src/lib.rs",
|
||||
".cargo_vcs_info.json",
|
||||
],
|
||||
&[(".cargo_vcs_info.json", &vcs_contents)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
|
|
Loading…
Reference in a new issue