feat(git): add authenticated fetch and dual sync badge
This updates the Windows taskbar overlay badge to show ahead and behind separately with distinct colors, and clears it when both are zero. It also adds a new authenticated fetch command wired through the Tauri backend and UI, including a silent background fetch to keep ahead/behind (and the badge) accurate without user interaction. - Add Windows dual badge rendering for ahead/behind - Implement Tauri fetch command with auth error handling - Add UI fetch action plus periodic background fetch updates
This commit is contained in:
@@ -717,6 +717,37 @@ pub fn pull(
|
||||
Err(format!("Git command failed: {details}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch(
|
||||
path: String,
|
||||
username: Option<String>,
|
||||
password: Option<String>,
|
||||
) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let fetch_args = ["fetch"];
|
||||
let output = match (username.as_deref(), password.as_deref()) {
|
||||
(Some(u), Some(p)) if !u.is_empty() || !p.is_empty() => {
|
||||
run_git_authenticated_output(&repo, fetch_args, u, p)?
|
||||
}
|
||||
_ => git_command()
|
||||
.arg("-C")
|
||||
.arg(&repo)
|
||||
.args(fetch_args)
|
||||
.output()
|
||||
.map_err(|err| format!("Could not start Git. Is Git installed? {err}"))?,
|
||||
};
|
||||
|
||||
if output.status.success() {
|
||||
return status_for_repo(&repo);
|
||||
}
|
||||
|
||||
let details = command_output_details(&output);
|
||||
if is_auth_error(&details) {
|
||||
return Err(format!("AUTH_FAILED:{details}"));
|
||||
}
|
||||
Err(format!("Git command failed: {details}"))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn push(
|
||||
path: String,
|
||||
|
||||
Reference in New Issue
Block a user