Add live git status indicators (#458)

This commit is contained in:
Gregory Schier
2026-05-08 11:25:39 -07:00
committed by GitHub
parent 1b154ba550
commit d7e67cf13c
35 changed files with 1702 additions and 578 deletions
+60 -6
View File
@@ -3,14 +3,18 @@
//! This module provides the Tauri commands for git functionality.
use crate::error::Result;
use crate::git_watcher::{GitWatchResult, watch_git_worktree_status};
use std::path::{Path, PathBuf};
use tauri::command;
use tauri::ipc::Channel;
use tauri::{AppHandle, Runtime, command};
use yaak_git::{
BranchDeleteResult, CloneResult, GitCommit, GitRemote, GitStatusSummary, PullResult,
PushResult, git_add, git_add_credential, git_add_remote, git_checkout_branch, git_clone,
git_commit, git_create_branch, git_delete_branch, git_delete_remote_branch, git_fetch_all,
git_init, git_log, git_merge_branch, git_pull, git_pull_force_reset, git_pull_merge, git_push,
git_remotes, git_rename_branch, git_reset_changes, git_rm_remote, git_status, git_unstage,
BranchDeleteResult, CloneResult, GitBranchInfo, GitCommit, GitFileDiff, GitRemote,
GitStatusSummary, GitWorktreeStatus, PullResult, PushResult, git_add, git_add_credential,
git_add_remote, git_branch_info, git_checkout_branch, git_clone, git_commit, git_create_branch,
git_delete_branch, git_delete_remote_branch, git_fetch_all, git_file_diff_for_commit, git_init,
git_log, git_log_for_file, git_merge_branch, git_pull, git_pull_force_reset, git_pull_merge,
git_push, git_remotes, git_rename_branch, git_reset_changes, git_restore,
git_restore_file_from_commit, git_rm_remote, git_status, git_unstage, git_worktree_status,
};
// NOTE: All of these commands are async to prevent blocking work from locking up the UI
@@ -54,11 +58,44 @@ pub async fn cmd_git_status(dir: &Path) -> Result<GitStatusSummary> {
Ok(git_status(dir)?)
}
#[command]
pub async fn cmd_git_branch_info(dir: &Path) -> Result<GitBranchInfo> {
Ok(git_branch_info(dir)?)
}
#[command]
pub async fn cmd_git_worktree_status(dir: &Path) -> Result<GitWorktreeStatus> {
Ok(git_worktree_status(dir)?)
}
#[command]
pub async fn cmd_git_watch_worktree_status<R: Runtime>(
app_handle: AppHandle<R>,
dir: &Path,
channel: Channel<GitWorktreeStatus>,
) -> Result<GitWatchResult> {
watch_git_worktree_status(app_handle, dir, channel).await
}
#[command]
pub async fn cmd_git_log(dir: &Path) -> Result<Vec<GitCommit>> {
Ok(git_log(dir)?)
}
#[command]
pub async fn cmd_git_log_for_file(dir: &Path, rela_path: PathBuf) -> Result<Vec<GitCommit>> {
Ok(git_log_for_file(dir, &rela_path)?)
}
#[command]
pub async fn cmd_git_file_diff_for_commit(
dir: &Path,
commit_oid: &str,
rela_path: PathBuf,
) -> Result<GitFileDiff> {
Ok(git_file_diff_for_commit(dir, commit_oid, &rela_path)?)
}
#[command]
pub async fn cmd_git_initialize(dir: &Path) -> Result<()> {
Ok(git_init(dir)?)
@@ -124,6 +161,23 @@ pub async fn cmd_git_reset_changes(dir: &Path) -> Result<()> {
Ok(git_reset_changes(dir).await?)
}
#[command]
pub async fn cmd_git_restore_files(dir: &Path, rela_paths: Vec<PathBuf>) -> Result<()> {
for path in rela_paths {
git_restore(dir, &path)?;
}
Ok(())
}
#[command]
pub async fn cmd_git_restore_file_from_commit(
dir: &Path,
commit_oid: &str,
rela_path: PathBuf,
) -> Result<()> {
Ok(git_restore_file_from_commit(dir, commit_oid, &rela_path)?)
}
#[command]
pub async fn cmd_git_add_credential(
remote_url: &str,