mirror of
https://github.com/rzmk/commit-helper.git
synced 2025-12-19 05:29:24 +00:00
feat: add suggested descriptions for each commit type
This commit is contained in:
parent
7bc9aac560
commit
5169c4bc07
1 changed files with 17 additions and 4 deletions
21
src/main.rs
21
src/main.rs
|
|
@ -16,11 +16,24 @@ fn main() {
|
||||||
|
|
||||||
// Commit Type
|
// Commit Type
|
||||||
let commit_type_options = vec![
|
let commit_type_options = vec![
|
||||||
"build", "ci", "chore", "docs", "feat", "fix", "perf", "refactor", "test",
|
"build - build system and dependencies",
|
||||||
|
"ci - continuous integration",
|
||||||
|
"chore - misc/maintenance not related to core code",
|
||||||
|
"docs - documentation changes (e.g., README.md, comments)",
|
||||||
|
"feat - new feature or significant enhancement",
|
||||||
|
"fix - bug fix or error correction",
|
||||||
|
"perf - performance improvement",
|
||||||
|
"refactor - code restructuring or cleanup",
|
||||||
|
"test - add or update tests",
|
||||||
];
|
];
|
||||||
let commit_type = Select::new("Type:", commit_type_options).prompt();
|
let commit_type = Select::new("Type:", commit_type_options).prompt();
|
||||||
let commit_type = match commit_type {
|
let commit_type = match commit_type {
|
||||||
Ok(commit_type) => String::from(commit_type),
|
Ok(commit_type) =>
|
||||||
|
// Get the first word of the commit type
|
||||||
|
{
|
||||||
|
let commit_type = commit_type.split_whitespace().next().unwrap();
|
||||||
|
commit_type
|
||||||
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
println!("No commit type selected, exiting");
|
println!("No commit type selected, exiting");
|
||||||
return;
|
return;
|
||||||
|
|
@ -45,7 +58,7 @@ fn main() {
|
||||||
|
|
||||||
match confirm {
|
match confirm {
|
||||||
Ok(true) => {
|
Ok(true) => {
|
||||||
if run_git_add == true {
|
if run_git_add {
|
||||||
println!("Running git add -A");
|
println!("Running git add -A");
|
||||||
if !dry_run {
|
if !dry_run {
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
|
|
@ -63,7 +76,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Running git commit -m \"{}\"", result_message);
|
println!("Running git commit -m \"{}\"", result_message);
|
||||||
if dry_run == false {
|
if !dry_run {
|
||||||
let output = Command::new("git")
|
let output = Command::new("git")
|
||||||
.args(["commit", "-m", result_message.as_str()])
|
.args(["commit", "-m", result_message.as_str()])
|
||||||
.output()
|
.output()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue