feat(commit): 添加提交消息模板支持
- 移除 config 命令中未使用的 List 子命令及相关显示字段 - 统一 ChangelogCommand 和 CommitCommand 的 ContentGenerator 初始化方式
This commit is contained in:
@@ -7,16 +7,21 @@ use anyhow::{Context, Result};
|
||||
/// Content generator using LLM
|
||||
pub struct ContentGenerator {
|
||||
llm_client: LlmClient,
|
||||
template: Option<String>,
|
||||
}
|
||||
|
||||
impl ContentGenerator {
|
||||
/// Create new content generator
|
||||
pub async fn new(manager: &ConfigManager) -> Result<Self> {
|
||||
Self::new_with_think(manager, false).await
|
||||
Self::new_with_think(manager, false, None).await
|
||||
}
|
||||
|
||||
/// Create new content generator with thinking override
|
||||
pub async fn new_with_think(manager: &ConfigManager, think_override: bool) -> Result<Self> {
|
||||
/// Create new content generator with thinking override and optional commit template
|
||||
pub async fn new_with_think(
|
||||
manager: &ConfigManager,
|
||||
think_override: bool,
|
||||
template: Option<String>,
|
||||
) -> Result<Self> {
|
||||
let mut thinking_enabled = if think_override {
|
||||
true
|
||||
} else {
|
||||
@@ -42,7 +47,10 @@ impl ContentGenerator {
|
||||
anyhow::bail!("LLM provider '{}' is not available", manager.llm_provider());
|
||||
}
|
||||
|
||||
Ok(Self { llm_client })
|
||||
Ok(Self {
|
||||
llm_client,
|
||||
template,
|
||||
})
|
||||
}
|
||||
|
||||
fn supports_thinking(provider: &str) -> bool {
|
||||
@@ -66,7 +74,7 @@ impl ContentGenerator {
|
||||
};
|
||||
|
||||
self.llm_client
|
||||
.generate_commit_message(&truncated_diff, format, language)
|
||||
.generate_commit_message(&truncated_diff, format, language, self.template.as_deref())
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user