mirror of
https://github.com/rzmk/commit-helper.git
synced 2025-12-19 05:29:24 +00:00
feat: add -p flag for git push after commit
This commit is contained in:
parent
5cd3c35814
commit
2b8d4b103e
4 changed files with 29 additions and 2 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -11,6 +11,8 @@ fn main() {
|
|||
if dry_run {
|
||||
println!("Running in dry run mode\n");
|
||||
}
|
||||
// Check if -p flag is passed to run git push after commit
|
||||
let run_git_push = args.len() > 1 && args.contains(&String::from("-p"));
|
||||
// Check if --debug flag is passed to run in debug mode
|
||||
let debug = args.len() > 1 && args.contains(&String::from("--debug"));
|
||||
|
||||
|
|
@ -89,6 +91,23 @@ fn main() {
|
|||
println!("Exit status:\n{}", output.status);
|
||||
}
|
||||
}
|
||||
|
||||
if run_git_push {
|
||||
println!("Running git push");
|
||||
if !dry_run {
|
||||
let output = Command::new("git")
|
||||
.args(["push"])
|
||||
.output()
|
||||
.expect("failed to execute process");
|
||||
|
||||
if debug {
|
||||
println!("Debug info:");
|
||||
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
|
||||
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
|
||||
println!("Exit status:\n{}", output.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
println!("Exiting");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue