1
0
mirror of https://github.com/j178/prek.git synced 2026-04-25 02:11:36 +02:00

Fix missing commit hash from version info (#1352)

This commit is contained in:
Jo
2026-01-14 16:02:07 +08:00
committed by GitHub
parent 328534fc8b
commit 2e1ffa313f
2 changed files with 28 additions and 1 deletions
+6 -1
View File
@@ -30,7 +30,12 @@ fn main() {
// The workspace root directory is not available without walking up the tree
// https://github.com/rust-lang/cargo/issues/3946
#[allow(clippy::disallowed_methods)]
let workspace_root = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).to_path_buf();
let workspace_root = Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap())
.parent()
.expect("CARGO_MANIFEST_DIR should be nested in workspace")
.parent()
.expect("CARGO_MANIFEST_DIR should be doubly nested in workspace")
.to_path_buf();
commit_info(&workspace_root);
}
+22
View File
@@ -2785,3 +2785,25 @@ fn run_with_stdin_closed() {
----- stderr -----
");
}
/// Test `prek --version` outputs version info.
#[test]
fn version_info() {
let context = TestContext::new();
let filters = context
.filters()
.into_iter()
.chain([(
r"prek \d+\.\d+\.\d+(-[0-9A-Za-z]+(\.[0-9A-Za-z]+)*)?(\+\d+)? \(\w{9} [\d\-T:\.]+\)",
"prek [CURRENT_VERSION] ([COMMIT] [DATE])",
)])
.collect::<Vec<_>>();
cmd_snapshot!(filters, context.command().arg("--version"), @r"
success: true
exit_code: 0
----- stdout -----
prek [CURRENT_VERSION] ([COMMIT] [DATE])
----- stderr -----
");
}