aboutsummaryrefslogtreecommitdiff
path: root/dev_tools/src/bin/ci.rs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-31 02:42:52 +0800
committer魏曹先生 <1992414357@qq.com>2026-05-31 17:19:20 +0800
commit2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 (patch)
treef10b89007fc67ca1a948f34abe6869b49296b932 /dev_tools/src/bin/ci.rs
parent3aa409a55e4f2f0ab41b0949cc06eb13c2da4a43 (diff)
Enhance code quality across the entire codebase
Diffstat (limited to 'dev_tools/src/bin/ci.rs')
-rw-r--r--dev_tools/src/bin/ci.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/dev_tools/src/bin/ci.rs b/dev_tools/src/bin/ci.rs
index 3169b95..86b930c 100644
--- a/dev_tools/src/bin/ci.rs
+++ b/dev_tools/src/bin/ci.rs
@@ -1,4 +1,4 @@
-use std::io::Write;
+use std::io::Write as _;
use std::process::exit;
use tools::{cargo_tomls, eprintln_cargo_style, println_cargo_style, run_cmd};
@@ -26,7 +26,7 @@ fn main() {
}
if let Err(exit_code) = ci() {
- restore_workspace().unwrap();
+ restore_workspace(needs_commit_temp).unwrap();
exit(exit_code)
}
@@ -39,7 +39,7 @@ fn main() {
let _ = run_cmd!("git status");
if needs_commit_temp {
- restore_workspace().unwrap();
+ restore_workspace(true).unwrap();
}
exit(1)
}
@@ -47,14 +47,16 @@ fn main() {
println_cargo_style!("Done: All check passed!");
if needs_commit_temp {
- restore_workspace().unwrap();
+ restore_workspace(true).unwrap();
}
}
-fn restore_workspace() -> Result<(), i32> {
+fn restore_workspace(undo_commit: bool) -> Result<(), i32> {
run_cmd!("git reset --hard --quiet")?;
- run_cmd!("git reset --soft HEAD~1 --quiet")?;
- run_cmd!("git reset --quiet")?;
+ if undo_commit {
+ run_cmd!("git reset --soft HEAD~1 --quiet")?;
+ run_cmd!("git reset --quiet")?;
+ }
Ok(())
}