From c9073ff4a708927cc1073a385d37efc4a1a3ca9c Mon Sep 17 00:00:00 2001 From: SidneyZhang Date: Wed, 4 Feb 2026 10:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(profile)=EF=BC=9A=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AE=BE=E7=BD=AEGPG=E7=AD=BE=E5=90=8D=E5=92=8CSSH?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20=E2=99=BB=EF=B8=8F=20refactor(generator)?= =?UTF-8?q?=EF=BC=9A=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=92=8C=E5=89=AA=E8=B4=B4=E6=9D=BF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=E2=99=BB=EF=B8=8F=20refactor(git)=EF=BC=9A?= =?UTF-8?q?=E6=B8=85=E7=90=86=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=92=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93?= =?UTF-8?q?=E6=9E=84=20=E2=99=BB=EF=B8=8F=20refactor(i18n)=EF=BC=9A?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E7=BF=BB=E8=AF=91=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E7=BB=93=E6=9E=84=20=E2=99=BB=EF=B8=8F=20ref?= =?UTF-8?q?actor(llm)=EF=BC=9A=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=BA=8F=E5=88=97=E5=8C=96=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=20=E2=99=BB=EF=B8=8F=20refactor(openrouter)=EF=BC=9A=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E6=A8=A1=E5=9E=8B=E9=AA=8C=E8=AF=81=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/profile.rs | 10 +++++++++- src/config/profile.rs | 15 +++++++++++++++ src/generator/mod.rs | 20 +++----------------- src/git/changelog.rs | 4 +--- src/git/commit.rs | 2 +- src/git/mod.rs | 4 ---- src/git/tag.rs | 2 +- src/i18n/mod.rs | 2 -- src/llm/mod.rs | 1 - src/llm/openrouter.rs | 2 +- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/commands/profile.rs b/src/commands/profile.rs index d038623..7d7523d 100644 --- a/src/commands/profile.rs +++ b/src/commands/profile.rs @@ -437,10 +437,18 @@ impl ProfileCommand { let repo_path = repo.path().to_string_lossy().to_string(); - manager.set_repo_profile(repo_path, name.to_string())?; + manager.set_repo_profile(repo_path.clone(), name.to_string())?; + + // Get the profile and apply it to the repository + let profile = manager.get_profile(name) + .ok_or_else(|| anyhow::anyhow!("Profile '{}' not found", name))?; + + profile.apply_to_repo(repo.inner())?; + manager.record_profile_usage(name, Some(repo_path))?; manager.save()?; println!("{} Set '{}' for current repository", "✓".green(), name.cyan()); + println!("{} Applied profile '{}' to current repository", "✓".green(), name.cyan()); Ok(()) } diff --git a/src/config/profile.rs b/src/config/profile.rs index b1cad0c..bb8c1d5 100644 --- a/src/config/profile.rs +++ b/src/config/profile.rs @@ -194,6 +194,21 @@ impl GitProfile { if let Some(key) = self.signing_key() { config.set_str("user.signingkey", key)?; + + if self.settings.auto_sign_commits { + config.set_bool("commit.gpgsign", true)?; + } + + if self.settings.auto_sign_tags { + config.set_bool("tag.gpgsign", true)?; + } + } + + if let Some(ref ssh) = self.ssh { + if let Some(ref key_path) = ssh.private_key_path { + config.set_str("core.sshCommand", + &format!("ssh -i {}", key_path.display()))?; + } } Ok(()) diff --git a/src/generator/mod.rs b/src/generator/mod.rs index a637ae4..c082bd7 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -2,7 +2,6 @@ use crate::config::{CommitFormat, LlmConfig, Language}; use crate::git::{CommitInfo, GitRepo}; use crate::llm::{GeneratedCommit, LlmClient}; use anyhow::{Context, Result}; -use chrono::Utc; /// Content generator using LLM pub struct ContentGenerator { @@ -114,8 +113,7 @@ impl ContentGenerator { format: CommitFormat, language: Language, ) -> Result { - use dialoguer::{Confirm, Select}; - use console::Term; + use dialoguer::Select; let diff = repo.get_staged_diff()?; @@ -145,7 +143,6 @@ impl ContentGenerator { "✓ Accept and commit", "🔄 Regenerate", "✏️ Edit", - "📋 Copy to clipboard", "❌ Cancel", ]; @@ -165,24 +162,13 @@ impl ContentGenerator { let edited = crate::utils::editor::edit_content(&generated.to_conventional())?; generated = self.parse_edited_commit(&edited, format)?; } - 3 => { - #[cfg(feature = "clipboard")] - { - arboard::Clipboard::new()?.set_text(generated.to_conventional())?; - println!("Copied to clipboard!"); - } - #[cfg(not(feature = "clipboard"))] - { - println!("Clipboard feature not enabled"); - } - } - 4 => anyhow::bail!("Cancelled by user"), + 3 => anyhow::bail!("Cancelled by user"), _ => {} } } } - fn parse_edited_commit(&self, edited: &str, format: CommitFormat) -> Result { + fn parse_edited_commit(&self, edited: &str, _format: CommitFormat) -> Result { let parsed = crate::git::commit::parse_commit_message(edited); Ok(GeneratedCommit { diff --git a/src/git/changelog.rs b/src/git/changelog.rs index ead0f78..d09600b 100644 --- a/src/git/changelog.rs +++ b/src/git/changelog.rs @@ -1,6 +1,6 @@ use super::{CommitInfo, GitRepo}; use anyhow::{Context, Result}; -use chrono::{DateTime, TimeZone, Utc}; +use chrono::{DateTime, Utc}; use std::collections::HashMap; use std::fs; use std::path::Path; @@ -232,8 +232,6 @@ impl ChangelogGenerator { let mut breaking = vec![]; for commit in commits { - let msg = commit.subject(); - if commit.message.contains("BREAKING CHANGE") { breaking.push(commit); } diff --git a/src/git/commit.rs b/src/git/commit.rs index 1807025..dbfaa26 100644 --- a/src/git/commit.rs +++ b/src/git/commit.rs @@ -1,5 +1,5 @@ use super::GitRepo; -use anyhow::{bail, Context, Result}; +use anyhow::{bail, Result}; use chrono::Local; /// Commit builder for creating commits diff --git a/src/git/mod.rs b/src/git/mod.rs index de4882e..fc754e4 100644 --- a/src/git/mod.rs +++ b/src/git/mod.rs @@ -8,10 +8,6 @@ pub mod changelog; pub mod commit; pub mod tag; -pub use changelog::ChangelogGenerator; -pub use commit::CommitBuilder; -pub use tag::TagBuilder; - /// Git repository wrapper with enhanced cross-platform support pub struct GitRepo { repo: Repository, diff --git a/src/git/tag.rs b/src/git/tag.rs index e14526a..93c4edc 100644 --- a/src/git/tag.rs +++ b/src/git/tag.rs @@ -1,5 +1,5 @@ use super::GitRepo; -use anyhow::{bail, Context, Result}; +use anyhow::{bail, Result}; use semver::Version; /// Tag builder for creating tags diff --git a/src/i18n/mod.rs b/src/i18n/mod.rs index 4b07f2c..30c6237 100644 --- a/src/i18n/mod.rs +++ b/src/i18n/mod.rs @@ -2,6 +2,4 @@ pub mod messages; pub mod translator; pub use messages::Messages; -pub use translator::Translator; -pub use translator::translate_commit_type; pub use translator::translate_changelog_category; diff --git a/src/llm/mod.rs b/src/llm/mod.rs index 44794fd..f5ae849 100644 --- a/src/llm/mod.rs +++ b/src/llm/mod.rs @@ -1,6 +1,5 @@ use anyhow::{bail, Context, Result}; use async_trait::async_trait; -use serde::{Deserialize, Serialize}; use std::time::Duration; use crate::config::Language; diff --git a/src/llm/openrouter.rs b/src/llm/openrouter.rs index 0f4c7ed..8b0f0f6 100644 --- a/src/llm/openrouter.rs +++ b/src/llm/openrouter.rs @@ -239,7 +239,7 @@ pub const OPENROUTER_MODELS: &[&str] = &[ ]; /// Check if a model name is valid -pub fn is_valid_model(model: &str) -> bool { +pub fn is_valid_model(_model: &str) -> bool { // Since OpenRouter supports many models, we'll allow any model name // but provide some popular ones as suggestions true