Skip to content

Commit

Permalink
Skip serializing the dirty flag if false.
Browse files Browse the repository at this point in the history
  • Loading branch information
torhovland committed Jun 24, 2024
1 parent 0925e3e commit 8255ded
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,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

0 comments on commit 8255ded

Please sign in to comment.