Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <fslongjin@vip.qq.com>"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

## 使用
Expand Down
36 changes: 14 additions & 22 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down