feat(commit): 添加提交消息模板支持
- 移除 config 命令中未使用的 List 子命令及相关显示字段 - 统一 ChangelogCommand 和 CommitCommand 的 ContentGenerator 初始化方式
This commit is contained in:
@@ -37,9 +37,6 @@ enum ConfigSubcommand {
|
||||
/// Show current configuration
|
||||
Show,
|
||||
|
||||
/// List all configuration information (with masked API keys)
|
||||
List,
|
||||
|
||||
/// Edit configuration file
|
||||
Edit,
|
||||
|
||||
@@ -167,7 +164,6 @@ impl ConfigCommand {
|
||||
pub async fn execute(&self, config_path: Option<PathBuf>) -> Result<()> {
|
||||
match &self.command {
|
||||
Some(ConfigSubcommand::Show) => self.show_config(&config_path).await,
|
||||
Some(ConfigSubcommand::List) => self.list_config(&config_path).await,
|
||||
Some(ConfigSubcommand::Edit) => self.edit_config(&config_path).await,
|
||||
Some(ConfigSubcommand::Set { key, value }) => {
|
||||
self.set_value(key, value, &config_path).await
|
||||
@@ -311,15 +307,6 @@ impl ConfigCommand {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" GPG sign: {}",
|
||||
if config.commit.gpg_sign {
|
||||
"yes".green()
|
||||
} else {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(" Max subject length: {}", config.commit.max_subject_length);
|
||||
|
||||
println!("\n{}", "Tag Configuration:".bold());
|
||||
println!(" Version prefix: '{}'", config.tag.version_prefix);
|
||||
@@ -331,22 +318,6 @@ impl ConfigCommand {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" GPG sign: {}",
|
||||
if config.tag.gpg_sign {
|
||||
"yes".green()
|
||||
} else {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Include changelog: {}",
|
||||
if config.tag.include_changelog {
|
||||
"yes".green()
|
||||
} else {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
|
||||
println!("\n{}", "Language Configuration:".bold());
|
||||
let language = manager.get_language().unwrap_or(Language::English);
|
||||
@@ -378,243 +349,17 @@ impl ConfigCommand {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Include hashes: {}",
|
||||
if config.changelog.include_hashes {
|
||||
"yes".green()
|
||||
} else {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Include authors: {}",
|
||||
if config.changelog.include_authors {
|
||||
"yes".green()
|
||||
} else {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Group by type: {}",
|
||||
if config.changelog.group_by_type {
|
||||
"yes".green()
|
||||
} else {
|
||||
"no".red()
|
||||
}
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn list_config(&self, config_path: &Option<PathBuf>) -> Result<()> {
|
||||
let manager = self.get_manager(config_path)?;
|
||||
let config = manager.config();
|
||||
|
||||
println!("{}", "\nQuiCommit Configuration".bold());
|
||||
println!("{}", "═".repeat(80));
|
||||
|
||||
println!("\n{}", "📁 General Configuration:".bold().blue());
|
||||
println!(" Config file: {}", manager.path().display());
|
||||
println!("\n{}", "Security:".bold());
|
||||
println!(" Repository mappings: {} mapping(s)", config.repo_profiles.len());
|
||||
println!(
|
||||
" Default profile: {}",
|
||||
config.default_profile.as_deref().unwrap_or("(none)").cyan()
|
||||
);
|
||||
println!(" Profiles: {} profile(s)", config.profiles.len());
|
||||
println!(
|
||||
" Repository mappings: {} mapping(s)",
|
||||
config.repo_profiles.len()
|
||||
);
|
||||
|
||||
println!("\n{}", "🤖 LLM Configuration:".bold().blue());
|
||||
println!(" Provider: {}", config.llm.provider.cyan());
|
||||
println!(" Model: {}", config.llm.model.cyan());
|
||||
println!(" Base URL: {}", manager.llm_base_url());
|
||||
println!(
|
||||
" API Key: {}",
|
||||
mask_api_key(manager.get_api_key().as_deref())
|
||||
);
|
||||
println!(" Max tokens: {}", config.llm.max_tokens);
|
||||
println!(" Temperature: {}", config.llm.temperature);
|
||||
println!(" Timeout: {}s", config.llm.timeout);
|
||||
|
||||
println!("\n{}", "📝 Commit Configuration:".bold().blue());
|
||||
println!(" Format: {}", config.commit.format.to_string().cyan());
|
||||
println!(
|
||||
" Auto-generate: {}",
|
||||
if config.commit.auto_generate {
|
||||
"✓ yes".green()
|
||||
" Keyring: {}",
|
||||
if manager.keyring().is_available() {
|
||||
"available".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
"unavailable".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Allow empty: {}",
|
||||
if config.commit.allow_empty {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" GPG sign: {}",
|
||||
if config.commit.gpg_sign {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Default scope: {}",
|
||||
config
|
||||
.commit
|
||||
.default_scope
|
||||
.as_deref()
|
||||
.unwrap_or("(none)")
|
||||
.cyan()
|
||||
);
|
||||
println!(" Max subject length: {}", config.commit.max_subject_length);
|
||||
println!(
|
||||
" Require scope: {}",
|
||||
if config.commit.require_scope {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Require body: {}",
|
||||
if config.commit.require_body {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
if !config.commit.body_required_types.is_empty() {
|
||||
println!(
|
||||
" Body required types: {}",
|
||||
config.commit.body_required_types.join(", ").cyan()
|
||||
);
|
||||
}
|
||||
|
||||
println!("\n{}", "🏷️ Tag Configuration:".bold().blue());
|
||||
println!(" Version prefix: '{}'", config.tag.version_prefix.cyan());
|
||||
println!(
|
||||
" Auto-generate: {}",
|
||||
if config.tag.auto_generate {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" GPG sign: {}",
|
||||
if config.tag.gpg_sign {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Include changelog: {}",
|
||||
if config.tag.include_changelog {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Annotation template: {}",
|
||||
config
|
||||
.tag
|
||||
.annotation_template
|
||||
.as_deref()
|
||||
.unwrap_or("(none)")
|
||||
.cyan()
|
||||
);
|
||||
|
||||
println!("\n{}", "📋 Changelog Configuration:".bold().blue());
|
||||
println!(" Path: {}", config.changelog.path);
|
||||
println!(
|
||||
" Auto-generate: {}",
|
||||
if config.changelog.auto_generate {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Format: {}",
|
||||
format!("{:?}", config.changelog.format).cyan()
|
||||
);
|
||||
println!(
|
||||
" Include hashes: {}",
|
||||
if config.changelog.include_hashes {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Include authors: {}",
|
||||
if config.changelog.include_authors {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Group by type: {}",
|
||||
if config.changelog.group_by_type {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
if !config.changelog.custom_categories.is_empty() {
|
||||
println!(
|
||||
" Custom categories: {} category(ies)",
|
||||
config.changelog.custom_categories.len()
|
||||
);
|
||||
}
|
||||
|
||||
println!("\n{}", "🎨 Theme Configuration:".bold().blue());
|
||||
println!(
|
||||
" Colors: {}",
|
||||
if config.theme.colors {
|
||||
"✓ enabled".green()
|
||||
} else {
|
||||
"✗ disabled".red()
|
||||
}
|
||||
);
|
||||
println!(
|
||||
" Icons: {}",
|
||||
if config.theme.icons {
|
||||
"✓ enabled".green()
|
||||
} else {
|
||||
"✗ disabled".red()
|
||||
}
|
||||
);
|
||||
println!(" Date format: {}", config.theme.date_format.cyan());
|
||||
|
||||
println!("\n{}", "🔒 Security:".bold().blue());
|
||||
println!(
|
||||
" Encrypt sensitive: {}",
|
||||
if config.encrypt_sensitive {
|
||||
"✓ yes".green()
|
||||
} else {
|
||||
"✗ no".red()
|
||||
}
|
||||
);
|
||||
|
||||
println!("\n{}", "🔑 Keyring:".bold().blue());
|
||||
let keyring = manager.keyring();
|
||||
if keyring.is_available() {
|
||||
println!(" Status: {}", "✓ available".green());
|
||||
println!(" Backend: {}", keyring.get_status_message());
|
||||
} else {
|
||||
println!(" Status: {}", "✗ unavailable".red());
|
||||
println!(" Note: {}", keyring.get_status_message());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -671,7 +416,22 @@ impl ConfigCommand {
|
||||
manager.set_auto_generate_commits(value == "true");
|
||||
}
|
||||
"tag.version_prefix" => manager.set_version_prefix(value.to_string()),
|
||||
"tag.auto_generate" => {
|
||||
manager.config_mut().tag.auto_generate = value == "true";
|
||||
}
|
||||
"changelog.path" => manager.set_changelog_path(value.to_string()),
|
||||
"changelog.auto_generate" => {
|
||||
manager.config_mut().changelog.auto_generate = value == "true";
|
||||
}
|
||||
"language.output_language" => {
|
||||
manager.set_output_language(value.to_string());
|
||||
}
|
||||
"language.keep_types_english" => {
|
||||
manager.set_keep_types_english(value == "true");
|
||||
}
|
||||
"language.keep_changelog_types_english" => {
|
||||
manager.set_keep_changelog_types_english(value == "true");
|
||||
}
|
||||
_ => bail!("Unknown configuration key: {}", key),
|
||||
}
|
||||
|
||||
@@ -702,7 +462,14 @@ impl ConfigCommand {
|
||||
"commit.format" => config.commit.format.to_string(),
|
||||
"commit.auto_generate" => config.commit.auto_generate.to_string(),
|
||||
"tag.version_prefix" => config.tag.version_prefix.clone(),
|
||||
"tag.auto_generate" => config.tag.auto_generate.to_string(),
|
||||
"changelog.path" => config.changelog.path.clone(),
|
||||
"changelog.auto_generate" => config.changelog.auto_generate.to_string(),
|
||||
"language.output_language" => config.language.output_language.clone(),
|
||||
"language.keep_types_english" => config.language.keep_types_english.to_string(),
|
||||
"language.keep_changelog_types_english" => {
|
||||
config.language.keep_changelog_types_english.to_string()
|
||||
}
|
||||
_ => bail!("Unknown configuration key: {}", key),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user