LLM支持优化

This commit is contained in:
2026-05-26 17:43:42 +08:00
parent a08bc809bb
commit 4331b9306e
26 changed files with 2309 additions and 669 deletions

View File

@@ -119,9 +119,7 @@ impl GitProfile {
/// Get signing key (from GPG config or direct)
pub fn signing_key(&self) -> Option<&str> {
self.signing_key
.as_ref()
.map(|s| s.as_str())
self.signing_key.as_deref()
.or_else(|| self.gpg.as_ref().map(|g| g.key_id.as_str()))
}
@@ -175,8 +173,8 @@ impl GitProfile {
}
}
if let Some(ref ssh) = self.ssh {
if let Some(ref key_path) = ssh.private_key_path {
if let Some(ref ssh) = self.ssh
&& let Some(ref key_path) = ssh.private_key_path {
let path_str = key_path.display().to_string();
#[cfg(target_os = "windows")]
{
@@ -189,7 +187,6 @@ impl GitProfile {
&format!("ssh -i '{}'", path_str))?;
}
}
}
Ok(())
}
@@ -213,8 +210,8 @@ impl GitProfile {
}
}
if let Some(ref ssh) = self.ssh {
if let Some(ref key_path) = ssh.private_key_path {
if let Some(ref ssh) = self.ssh
&& let Some(ref key_path) = ssh.private_key_path {
let path_str = key_path.display().to_string();
#[cfg(target_os = "windows")]
{
@@ -227,7 +224,6 @@ impl GitProfile {
&format!("ssh -i '{}'", path_str))?;
}
}
}
Ok(())
}
@@ -264,8 +260,8 @@ impl GitProfile {
});
}
if let Some(profile_key) = self.signing_key() {
if git_signing_key.as_deref() != Some(profile_key) {
if let Some(profile_key) = self.signing_key()
&& git_signing_key.as_deref() != Some(profile_key) {
comparison.matches = false;
comparison.differences.push(ConfigDifference {
key: "user.signingkey".to_string(),
@@ -273,7 +269,6 @@ impl GitProfile {
git_value: git_signing_key.unwrap_or_else(|| "<not set>".to_string()),
});
}
}
Ok(comparison)
}
@@ -281,6 +276,7 @@ impl GitProfile {
/// Profile settings
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Default)]
pub struct ProfileSettings {
/// Automatically sign commits
#[serde(default)]
@@ -307,18 +303,6 @@ pub struct ProfileSettings {
pub commit_template: Option<String>,
}
impl Default for ProfileSettings {
fn default() -> Self {
Self {
auto_sign_commits: false,
auto_sign_tags: false,
default_commit_format: None,
repo_patterns: vec![],
llm_provider: None,
commit_template: None,
}
}
}
/// SSH configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -349,17 +333,15 @@ pub struct SshConfig {
impl SshConfig {
/// Validate SSH configuration
pub fn validate(&self) -> Result<()> {
if let Some(ref path) = self.private_key_path {
if !path.exists() {
if let Some(ref path) = self.private_key_path
&& !path.exists() {
bail!("SSH private key does not exist: {:?}", path);
}
}
if let Some(ref path) = self.public_key_path {
if !path.exists() {
if let Some(ref path) = self.public_key_path
&& !path.exists() {
bail!("SSH public key does not exist: {:?}", path);
}
}
Ok(())
}
@@ -495,7 +477,9 @@ impl TokenConfig {
/// Token type
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
#[derive(Default)]
pub enum TokenType {
#[default]
None,
Personal,
OAuth,
@@ -503,11 +487,6 @@ pub enum TokenType {
App,
}
impl Default for TokenType {
fn default() -> Self {
Self::None
}
}
impl std::fmt::Display for TokenType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {