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

Include vcs_info even if workspace is dirty #13960

Merged
merged 5 commits into from
Jun 24, 2024
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
Skip serializing the dirty flag if false.
  • Loading branch information
torhovland committed Jun 24, 2024
commit e7bfed103cdb31f2b65b2f8ba576405e268e9b98
1 change: 1 addition & 0 deletions src/cargo/ops/cargo_package.rs
weihanglo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ struct VcsInfo {
struct GitVcsInfo {
sha1: String,
/// Indicate whether or not the Git worktree is dirty.
#[serde(skip_serializing_if = "std::ops::Not::not")]
dirty: bool,
}

Expand Down
4 changes: 2 additions & 2 deletions src/doc/man/cargo-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ steps:
executable binary or example target. {{man "cargo-install" 1}} will use the
packaged lock file if the `--locked` flag is used.
- A `.cargo_vcs_info.json` file is included that contains information
about the current VCS checkout hash if available, and whether or not the
about the current VCS checkout hash if available, as well as a flag if the
worktree is dirty.
3. Extract the `.crate` file and build it to verify it can build.
- This will rebuild your package from scratch to ensure that it can be
Expand Down Expand Up @@ -59,7 +59,7 @@ Will generate a `.cargo_vcs_info.json` in the following format
}
```

`dirty` indicates whether or not the Git worktree was dirty when the package
`dirty` indicates that the Git worktree was dirty when the package
was built.

`path_in_vcs` will be set to a repo-relative path for packages
Expand Down
8 changes: 4 additions & 4 deletions src/doc/man/generated_txt/cargo-package.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ DESCRIPTION
packaged lock file if the --locked flag is used.

o A .cargo_vcs_info.json file is included that contains information
about the current VCS checkout hash if available, and whether or
not the worktree is dirty.
about the current VCS checkout hash if available, as well as a
flag if the worktree is dirty.

3. Extract the .crate file and build it to verify it can build.
o This will rebuild your package from scratch to ensure that it can
Expand All @@ -57,8 +57,8 @@ DESCRIPTION
"path_in_vcs": ""
}

dirty indicates whether or not the Git worktree was dirty when the
package was built.
dirty indicates that the Git worktree was dirty when the package was
built.

path_in_vcs will be set to a repo-relative path for packages in
subdirectories of the version control repository.
Expand Down
4 changes: 2 additions & 2 deletions src/doc/src/commands/cargo-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
executable binary or example target. [cargo-install(1)](cargo-install.html) will use the
packaged lock file if the `--locked` flag is used.
- A `.cargo_vcs_info.json` file is included that contains information
about the current VCS checkout hash if available, and whether or not the
about the current VCS checkout hash if available, as well as a flag if the
worktree is dirty.
3. Extract the `.crate` file and build it to verify it can build.
- This will rebuild your package from scratch to ensure that it can be
Expand Down Expand Up @@ -54,7 +54,7 @@ Will generate a `.cargo_vcs_info.json` in the following format
}
```

`dirty` indicates whether or not the Git worktree was dirty when the package
`dirty` indicates that the Git worktree was dirty when the package
was built.

`path_in_vcs` will be set to a repo-relative path for packages
Expand Down
4 changes: 2 additions & 2 deletions src/etc/man/cargo-package.1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ packaged lock file if the \fB\-\-locked\fR flag is used.
.sp
.RS 4
\h'-04'\(bu\h'+02'A \fB\&.cargo_vcs_info.json\fR file is included that contains information
about the current VCS checkout hash if available, and whether or not the
about the current VCS checkout hash if available, as well as a flag if the
worktree is dirty.
.RE
.RE
Expand Down Expand Up @@ -82,7 +82,7 @@ Will generate a \fB\&.cargo_vcs_info.json\fR in the following format
.fi
.RE
.sp
\fBdirty\fR indicates whether or not the Git worktree was dirty when the package
\fBdirty\fR indicates that the Git worktree was dirty when the package
was built.
.sp
\fBpath_in_vcs\fR will be set to a repo\-relative path for packages
Expand Down
9 changes: 3 additions & 6 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
let vcs_contents = format!(
r#"{{
"git": {{
"sha1": "{}",
"dirty": false
"sha1": "{}"
}},
"path_in_vcs": ""
}}
Expand Down Expand Up @@ -231,8 +230,7 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for
let vcs_contents = format!(
r#"{{
"git": {{
"sha1": "{}",
"dirty": false
"sha1": "{}"
}},
"path_in_vcs": "a/a"
}}
Expand Down Expand Up @@ -1272,8 +1270,7 @@ fn issue_13695_allowing_dirty_vcs_info_but_clean() {
".cargo_vcs_info.json",
r#"{
"git": {
"sha1": "[..]",
"dirty": false
"sha1": "[..]"
},
"path_in_vcs": ""
}"#,
Expand Down