diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-09 21:08:12 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-09 21:08:12 +0800 |
| commit | 92cccd9517e764508dfa0342ae2ea254661d0a8f (patch) | |
| tree | 126144392a2e399e0ce4226f3942c5d27e7dee45 /dev_tools/src/bin/ci.rs | |
| parent | f7ce99550595915efb3d3f7774095976cb3b763b (diff) | |
Add `-y` flag to skip the temp commit prompt
Diffstat (limited to 'dev_tools/src/bin/ci.rs')
| -rw-r--r-- | dev_tools/src/bin/ci.rs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/dev_tools/src/bin/ci.rs b/dev_tools/src/bin/ci.rs index a90c413..b7934e1 100644 --- a/dev_tools/src/bin/ci.rs +++ b/dev_tools/src/bin/ci.rs @@ -8,20 +8,28 @@ fn main() { let _ = colored::control::set_virtual_terminal(true); println!("{}", include_str!("../../../docs/res/ci_banner.txt")); + let args: Vec<String> = std::env::args().collect(); + let auto_yes = args.iter().any(|a| a == "-y"); + let needs_commit_temp = !{ run_cmd!("git diff-index --quiet HEAD --").is_ok() }; if needs_commit_temp { - print!("Working tree is not clean, temporarily commit? [y/N]:"); - std::io::stdout().flush().unwrap(); - let mut input = String::new(); - std::io::stdin().read_line(&mut input).unwrap(); - let input = input.trim(); - if input == "y" || input == "Y" || input == "yes" || input == "Yes" { + if auto_yes { run_cmd!("git add .").unwrap(); run_cmd!("git commit -m \"[DO NOT PUSH] CI TEMP [DO NOT PUSH]\"").unwrap(); } else { - eprintln_cargo_style!("Aborting."); - exit(2) + print!("Working tree is not clean, temporarily commit? [y/N]:"); + std::io::stdout().flush().unwrap(); + let mut input = String::new(); + std::io::stdin().read_line(&mut input).unwrap(); + let input = input.trim(); + if input == "y" || input == "Y" || input == "yes" || input == "Yes" { + run_cmd!("git add .").unwrap(); + run_cmd!("git commit -m \"[DO NOT PUSH] CI TEMP [DO NOT PUSH]\"").unwrap(); + } else { + eprintln_cargo_style!("Aborting."); + exit(2) + } } } |
