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.7.2"
version = "0.7.3"
description = "AI-based command line tool to quickly generate standardized commit messages."
edition = "2021"
authors = ["longjin <fslongjin@vip.qq.com>"]
Expand Down
4 changes: 2 additions & 2 deletions 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.7.2
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.7.3
```


Expand All @@ -31,7 +31,7 @@ NOTE: All common config can be configured via `~/.fastcommit/config.toml`
- `--conventional <CONVENTIONAL>`: Enable or disable conventional commit style analysis. Acceptable values are `true` or `false`.
- `-l, --language <LANGUAGE>`: Specify the language for the commit message. Acceptable values are `en` (English) or `zh` (Chinese).
- `-b, --generate-branch`: Generate branch name.
- `--branch-prefix`: prefix of the generated branch name
- `--branch-prefix <BRANCH_PREFIX>`, `--bp <BRANCH_PREFIX>`: prefix of the generated branch name
- `-m, --message`: Generate commit message (use with -b to output both)
- `-v, --verbosity <VERBOSITY>`: Set the detail level of the commit message. Acceptable values are `verbose` (detailed), `normal`, or `quiet` (concise). The default is `quiet`.
- `-p, --prompt <PROMPT>`: Additional prompt to help AI understand the commit context.
Expand Down
4 changes: 2 additions & 2 deletions 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.7.2
cargo install --git https://github.com/fslongjin/fastcommit --tag v0.7.3
```

## 使用
Expand All @@ -28,7 +28,7 @@ NOTE: All common config can be configured via `~/.fastcommit/config.toml`
- `--conventional <CONVENTIONAL>`: 启用或禁用规范提交风格分析。可选值为 `true` 或 `false`。
- `-l, --language <LANGUAGE>`: 指定提交信息的语言。可选值为 `en`(英文)或 `zh`(中文)。
- `-b, --generate-branch`: 生成分支名
- `--branch-prefix`: 生成的分支名的前缀
- `--branch-prefix <BRANCH_PREFIX>`, `--bp <BRANCH_PREFIX>`: 生成的分支名的前缀
- `-m, --message`: 生成提交信息(与 -b 一起使用可同时输出)
- `-v, --verbosity <VERBOSITY>`: 设置提交信息的详细级别。可选值为 `verbose`(详细)、`normal`(正常)或 `quiet`(简洁)。 默认为 `quiet`。
- `-p, --prompt <PROMPT>`: 额外的提示信息,帮助 AI 理解提交上下文。
Expand Down
4 changes: 2 additions & 2 deletions src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const RANDOM_PHRASES: &[&str] = &[
"🌈 生成彩虹般绚丽的提交信息...",
"⚡ 闪电般快速分析代码...",
"🎨 为你的代码添加艺术气息...",
"🕺 Gee Kee Tai May! Oh Baby! ",
"💃 Gee Kee 实在是太美! ",
"🕺 Gee Knee Tai May! Oh Baby! ",
"💃 Gee Knee 实在是太美! ",
"🎪 代码马戏团表演中...",
"🍵 喝杯茶,马上就好...",
"🎸 为代码变更谱写乐章...",
Expand Down
36 changes: 35 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ pub struct CommitArgs {
)]
pub generate_branch: bool,

#[clap(long, help = "Override branch prefix (default from config)")]
#[clap(
long,
visible_alias = "bp",
help = "Override branch prefix (default from config)"
)]
pub branch_prefix: Option<String>,

#[clap(
Expand Down Expand Up @@ -265,6 +269,36 @@ mod tests {
);
}

#[test]
fn test_branch_prefix_alias_top_level() {
let args = parse_args(["fastcommit", "--bp=feature/"]).unwrap();
assert!(args.command.is_none());
assert_eq!(args.commit_args.branch_prefix, Some("feature/".to_string()));
assert!(!args.commit_args.generate_branch);
}

#[test]
fn test_branch_prefix_alias_commit_subcommand() {
let args = parse_args(["fastcommit", "commit", "-b", "--bp=feature/"]).unwrap();
if let Some(Commands::Commit(commit_args)) = args.command {
assert!(commit_args.generate_branch);
assert_eq!(commit_args.branch_prefix, Some("feature/".to_string()));
} else {
panic!("Expected Commit subcommand");
}
}

#[test]
fn test_prompt_short_option_still_works_with_generate_branch() {
let args = parse_args(["fastcommit", "-b", "-p", "extra context"]).unwrap();
assert!(args.commit_args.generate_branch);
assert_eq!(
args.commit_args.common.prompt,
Some("extra context".to_string())
);
assert_eq!(args.commit_args.branch_prefix, None);
}

#[test]
fn test_auto_commit_option() {
// Test: fastcommit -c (auto commit after generating)
Expand Down
Loading