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
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -22,7 +22,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "commit-helper"
|
name = "commit-helper"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"inquire",
|
"inquire",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "commit-helper"
|
name = "commit-helper"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,14 @@ If you want to run `git add -A` before committing, use the `-a` flag
|
||||||
ch -a
|
ch -a
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `-p`
|
||||||
|
|
||||||
|
If you want to run `git push` after committing, use the `-p` flag
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ch -p
|
||||||
|
```
|
||||||
|
|
||||||
### `--dry-run` or `-d`
|
### `--dry-run` or `-d`
|
||||||
|
|
||||||
If you want to do a dry run without actually adding or committing, use the `-d` or `--dry-run` flag.
|
If you want to do a dry run without actually adding or committing, use the `-d` or `--dry-run` flag.
|
||||||
|
|
|
||||||
19
src/main.rs
19
src/main.rs
|
|
@ -11,6 +11,8 @@ fn main() {
|
||||||
if dry_run {
|
if dry_run {
|
||||||
println!("Running in dry run mode\n");
|
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
|
// Check if --debug flag is passed to run in debug mode
|
||||||
let debug = args.len() > 1 && args.contains(&String::from("--debug"));
|
let debug = args.len() > 1 && args.contains(&String::from("--debug"));
|
||||||
|
|
||||||
|
|
@ -89,6 +91,23 @@ fn main() {
|
||||||
println!("Exit status:\n{}", output.status);
|
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");
|
println!("Exiting");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue