feat(commit): 添加提交消息模板支持
- 移除 config 命令中未使用的 List 子命令及相关显示字段 - 统一 ChangelogCommand 和 CommitCommand 的 ContentGenerator 初始化方式
This commit is contained in:
@@ -17,10 +17,11 @@ pub struct AppConfig {
|
||||
pub version: String,
|
||||
|
||||
/// Default profile name
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub default_profile: Option<String>,
|
||||
|
||||
/// All configured profiles
|
||||
#[serde(default)]
|
||||
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||
pub profiles: HashMap<String, GitProfile>,
|
||||
|
||||
/// LLM configuration
|
||||
@@ -40,17 +41,9 @@ pub struct AppConfig {
|
||||
pub changelog: ChangelogConfig,
|
||||
|
||||
/// Repository-specific profile mappings
|
||||
#[serde(default)]
|
||||
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||
pub repo_profiles: HashMap<String, String>,
|
||||
|
||||
/// Whether to encrypt sensitive data
|
||||
#[serde(default = "default_true")]
|
||||
pub encrypt_sensitive: bool,
|
||||
|
||||
/// Theme settings
|
||||
#[serde(default)]
|
||||
pub theme: ThemeConfig,
|
||||
|
||||
/// Language settings
|
||||
#[serde(default)]
|
||||
pub language: LanguageConfig,
|
||||
@@ -67,8 +60,6 @@ impl Default for AppConfig {
|
||||
tag: TagConfig::default(),
|
||||
changelog: ChangelogConfig::default(),
|
||||
repo_profiles: HashMap::new(),
|
||||
encrypt_sensitive: true,
|
||||
theme: ThemeConfig::default(),
|
||||
language: LanguageConfig::default(),
|
||||
}
|
||||
}
|
||||
@@ -81,11 +72,12 @@ pub struct LlmConfig {
|
||||
#[serde(default = "default_llm_provider")]
|
||||
pub provider: String,
|
||||
|
||||
/// Model to use (stored in config, not in keyring)
|
||||
/// Model to use
|
||||
#[serde(default = "default_model")]
|
||||
pub model: String,
|
||||
|
||||
/// API base URL (optional, will use provider default if not set)
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub base_url: Option<String>,
|
||||
|
||||
/// Maximum tokens for generation
|
||||
@@ -104,8 +96,8 @@ pub struct LlmConfig {
|
||||
#[serde(default = "default_api_key_storage")]
|
||||
pub api_key_storage: String,
|
||||
|
||||
/// API key (stored in config for fallback, encrypted if encrypt_sensitive is true)
|
||||
#[serde(default)]
|
||||
/// API key (stored in config for fallback)
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub api_key: Option<String>,
|
||||
|
||||
/// Enable thinking/reasoning mode (deepseek, kimi, anthropic)
|
||||
@@ -113,7 +105,7 @@ pub struct LlmConfig {
|
||||
pub thinking_enabled: bool,
|
||||
|
||||
/// Budget tokens for thinking mode (Anthropic Claude 4)
|
||||
#[serde(default)]
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub thinking_budget_tokens: Option<u32>,
|
||||
}
|
||||
|
||||
@@ -148,33 +140,6 @@ pub struct CommitConfig {
|
||||
/// Enable AI generation by default
|
||||
#[serde(default = "default_true")]
|
||||
pub auto_generate: bool,
|
||||
|
||||
/// Allow empty commits
|
||||
#[serde(default)]
|
||||
pub allow_empty: bool,
|
||||
|
||||
/// Sign commits with GPG
|
||||
#[serde(default)]
|
||||
pub gpg_sign: bool,
|
||||
|
||||
/// Default scope (optional)
|
||||
pub default_scope: Option<String>,
|
||||
|
||||
/// Maximum subject length
|
||||
#[serde(default = "default_max_subject_length")]
|
||||
pub max_subject_length: usize,
|
||||
|
||||
/// Require scope
|
||||
#[serde(default)]
|
||||
pub require_scope: bool,
|
||||
|
||||
/// Require body for certain types
|
||||
#[serde(default)]
|
||||
pub require_body: bool,
|
||||
|
||||
/// Types that require body
|
||||
#[serde(default = "default_body_required_types")]
|
||||
pub body_required_types: Vec<String>,
|
||||
}
|
||||
|
||||
impl Default for CommitConfig {
|
||||
@@ -182,13 +147,6 @@ impl Default for CommitConfig {
|
||||
Self {
|
||||
format: default_commit_format(),
|
||||
auto_generate: true,
|
||||
allow_empty: false,
|
||||
gpg_sign: false,
|
||||
default_scope: None,
|
||||
max_subject_length: default_max_subject_length(),
|
||||
require_scope: false,
|
||||
require_body: false,
|
||||
body_required_types: default_body_required_types(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,18 +178,6 @@ pub struct TagConfig {
|
||||
/// Enable AI generation for tag messages
|
||||
#[serde(default = "default_true")]
|
||||
pub auto_generate: bool,
|
||||
|
||||
/// Sign tags with GPG
|
||||
#[serde(default)]
|
||||
pub gpg_sign: bool,
|
||||
|
||||
/// Include changelog in annotated tags
|
||||
#[serde(default = "default_true")]
|
||||
pub include_changelog: bool,
|
||||
|
||||
/// Default annotation template
|
||||
#[serde(default)]
|
||||
pub annotation_template: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for TagConfig {
|
||||
@@ -239,9 +185,6 @@ impl Default for TagConfig {
|
||||
Self {
|
||||
version_prefix: default_version_prefix(),
|
||||
auto_generate: true,
|
||||
gpg_sign: false,
|
||||
include_changelog: true,
|
||||
annotation_template: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,26 +199,6 @@ pub struct ChangelogConfig {
|
||||
/// Enable AI generation for changelog entries
|
||||
#[serde(default = "default_true")]
|
||||
pub auto_generate: bool,
|
||||
|
||||
/// Changelog format
|
||||
#[serde(default = "default_changelog_format")]
|
||||
pub format: ChangelogFormat,
|
||||
|
||||
/// Include commit hashes
|
||||
#[serde(default)]
|
||||
pub include_hashes: bool,
|
||||
|
||||
/// Include authors
|
||||
#[serde(default)]
|
||||
pub include_authors: bool,
|
||||
|
||||
/// Group by type
|
||||
#[serde(default = "default_true")]
|
||||
pub group_by_type: bool,
|
||||
|
||||
/// Custom categories
|
||||
#[serde(default)]
|
||||
pub custom_categories: Vec<ChangelogCategory>,
|
||||
}
|
||||
|
||||
impl Default for ChangelogConfig {
|
||||
@@ -283,56 +206,6 @@ impl Default for ChangelogConfig {
|
||||
Self {
|
||||
path: default_changelog_path(),
|
||||
auto_generate: true,
|
||||
format: default_changelog_format(),
|
||||
include_hashes: false,
|
||||
include_authors: false,
|
||||
group_by_type: true,
|
||||
custom_categories: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Changelog format
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum ChangelogFormat {
|
||||
KeepAChangelog,
|
||||
GitHubReleases,
|
||||
Custom,
|
||||
}
|
||||
|
||||
/// Changelog category mapping
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ChangelogCategory {
|
||||
/// Category title
|
||||
pub title: String,
|
||||
|
||||
/// Commit types included in this category
|
||||
pub types: Vec<String>,
|
||||
}
|
||||
|
||||
/// Theme configuration
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ThemeConfig {
|
||||
/// Enable colors
|
||||
#[serde(default = "default_true")]
|
||||
pub colors: bool,
|
||||
|
||||
/// Enable icons
|
||||
#[serde(default = "default_true")]
|
||||
pub icons: bool,
|
||||
|
||||
/// Preferred date format
|
||||
#[serde(default = "default_date_format")]
|
||||
pub date_format: String,
|
||||
}
|
||||
|
||||
impl Default for ThemeConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
colors: true,
|
||||
icons: true,
|
||||
date_format: default_date_format(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,6 +288,7 @@ impl Language {
|
||||
}
|
||||
|
||||
// Default value functions
|
||||
|
||||
fn default_version() -> String {
|
||||
"1".to_string()
|
||||
}
|
||||
@@ -447,14 +321,6 @@ fn default_commit_format() -> CommitFormat {
|
||||
CommitFormat::Conventional
|
||||
}
|
||||
|
||||
fn default_max_subject_length() -> usize {
|
||||
100
|
||||
}
|
||||
|
||||
fn default_body_required_types() -> Vec<String> {
|
||||
vec!["feat".to_string(), "fix".to_string()]
|
||||
}
|
||||
|
||||
fn default_version_prefix() -> String {
|
||||
"v".to_string()
|
||||
}
|
||||
@@ -463,14 +329,6 @@ fn default_changelog_path() -> String {
|
||||
"CHANGELOG.md".to_string()
|
||||
}
|
||||
|
||||
fn default_changelog_format() -> ChangelogFormat {
|
||||
ChangelogFormat::KeepAChangelog
|
||||
}
|
||||
|
||||
fn default_date_format() -> String {
|
||||
"%Y-%m-%d".to_string()
|
||||
}
|
||||
|
||||
fn default_output_language() -> String {
|
||||
"en".to_string()
|
||||
}
|
||||
@@ -509,21 +367,6 @@ impl AppConfig {
|
||||
let config_dir = dirs::config_dir().context("Could not find config directory")?;
|
||||
Ok(config_dir.join("quicommit").join("config.toml"))
|
||||
}
|
||||
|
||||
// /// Get profile for a repository
|
||||
// pub fn get_profile_for_repo(&self, repo_path: &str) -> Option<&GitProfile> {
|
||||
// let profile_name = self.repo_profiles.get(repo_path)?;
|
||||
// self.profiles.get(profile_name)
|
||||
// }
|
||||
|
||||
// /// Set profile for a repository
|
||||
// pub fn set_profile_for_repo(&mut self, repo_path: String, profile_name: String) -> Result<()> {
|
||||
// if !self.profiles.contains_key(&profile_name) {
|
||||
// anyhow::bail!("Profile '{}' does not exist", profile_name);
|
||||
// }
|
||||
// self.repo_profiles.insert(repo_path, profile_name);
|
||||
// Ok(())
|
||||
// }
|
||||
}
|
||||
|
||||
/// Encrypted PAT data for export
|
||||
|
||||
Reference in New Issue
Block a user