diff --git a/Cargo.lock b/Cargo.lock index 0feca44..b51fffc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -359,7 +359,7 @@ dependencies = [ [[package]] name = "fastcommit" -version = "0.5.0" +version = "0.5.1" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 1929da2..6c5c5d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fastcommit" -version = "0.5.0" +version = "0.5.1" description = "AI-based command line tool to quickly generate standardized commit messages." edition = "2021" authors = ["longjin "] diff --git a/README.md b/README.md index f71938f..fd0dbf2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You can install `fastcommit` using the following method: ```bash # Install using cargo -cargo install --git https://github.com/fslongjin/fastcommit --tag v0.5.0 +cargo install --git https://github.com/fslongjin/fastcommit --tag v0.5.1 ``` diff --git a/README_CN.md b/README_CN.md index 06665d6..c3473c0 100644 --- a/README_CN.md +++ b/README_CN.md @@ -8,7 +8,7 @@ ```bash # 使用 cargo 安装 -cargo install --git https://github.com/fslongjin/fastcommit --tag v0.5.0 +cargo install --git https://github.com/fslongjin/fastcommit --tag v0.5.1 ``` ## 使用 diff --git a/src/main.rs b/src/main.rs index 579fdca..0e8060c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,40 +52,32 @@ async fn main() -> anyhow::Result<()> { run_update_checker().await; - // 根据参数决定生成内容: - // 1. --gb --m 同时:生成分支名 + 提交信息 - // 2. 仅 --gb:只生成分支名 - // 3. 默认(无 --gb 或仅 --m):生成提交信息 + // 创建提交消息专用的包装器(启用段落保留) + let commit_wrapper = if enable_wrapping { + let wrap_config = + WrapConfig::from_config_and_args(&config.text_wrap, args.wrap_width, true); + Some(TextWrapper::new(wrap_config)) + } else { + None + }; + // 根据参数决定生成内容 if args.generate_branch && args.generate_message { + // 生成分支名 + 提交信息 let (branch_name, msg) = generate::generate_both(&args, &config).await?; - // 停止spinner动画 spinner.finish(); - print_wrapped_content(&wrapper, &branch_name, Some("Generated branch name:")); - print_wrapped_content(&wrapper, &msg, None); + print_wrapped_content(&commit_wrapper, &msg, None); } else if args.generate_branch { + // 仅生成分支名 let branch_name = generate::generate_branch(&args, &config).await?; - // 停止spinner动画 spinner.finish(); - print_wrapped_content(&wrapper, &branch_name, Some("Generated branch name:")); } else { - // 包括:无参数 或 仅 --m + // 仅生成提交信息(默认行为) let msg = generate::generate(&args, &config).await?; - // 停止spinner动画 spinner.finish(); - - // 对于提交消息,需要启用段落保留 - let final_wrapper = if enable_wrapping { - let wrap_config = - WrapConfig::from_config_and_args(&config.text_wrap, args.wrap_width, true); - Some(TextWrapper::new(wrap_config)) - } else { - None - }; - - print_wrapped_content(&final_wrapper, &msg, None); + print_wrapped_content(&commit_wrapper, &msg, None); } Ok(()) }