feat: implement default Git identity management and local identity check
This commit is contained in:
@@ -2029,6 +2029,27 @@ pub async fn get_current_git_identity(
|
||||
})
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn has_local_identity(
|
||||
directory: String,
|
||||
state: State<'_, DesktopRuntime>,
|
||||
) -> Result<bool, String> {
|
||||
let root = validate_git_path(&directory, state.settings())
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let user_name = run_git(&["config", "--local", "--get", "user.name"], &root)
|
||||
.await
|
||||
.ok()
|
||||
.filter(|s| !s.is_empty());
|
||||
let user_email = run_git(&["config", "--local", "--get", "user.email"], &root)
|
||||
.await
|
||||
.ok()
|
||||
.filter(|s| !s.is_empty());
|
||||
|
||||
Ok(user_name.is_some() || user_email.is_some())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_global_git_identity() -> Result<GitIdentitySummary, String> {
|
||||
let user_name = tokio::process::Command::new("git")
|
||||
|
||||
Reference in New Issue
Block a user