From c20814c48fa0a2ded78fc448067c7b918d9850d2 Mon Sep 17 00:00:00 2001 From: longjin Date: Wed, 8 Oct 2025 13:53:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(fastcommit):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=A1=E6=81=AF=E6=8D=A2=E8=A1=8C=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 重构代码结构,提取重复逻辑 - 创建专用的提交消息包装器 - 确保提交信息正确保留换行格式 Signed-off-by: longjin --- src/main.rs | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) 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(()) } From 66cace52ec441f0feb03210bcd2980e89fa9cb45 Mon Sep 17 00:00:00 2001 From: longjin Date: Wed, 8 Oct 2025 13:54:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore(version):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E8=87=B3=200.5.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: longjin --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- README_CN.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 ``` ## 使用