Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 159 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ ureq = { version = "2", features = ["json"] }
# project rule (guards returned directly, no poison-unwrap boilerplate).
parking_lot = "0.12"
thiserror = "2"
# Filesystem watcher for the .git dir, so external git ops (CLI, other tools) and
# checkouts/commits reflect instantly without a manual refresh. -mini wraps notify
# with built-in debounce, collapsing the write burst a single git op produces into
# one event. macOS backend is FSEvents (no openssl), so it cross-compiles like the
# rest.
notify-debouncer-mini = "0.4"

[profile.dev]
incremental = true
19 changes: 18 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod error;
mod git;
mod watch;

use error::AppResult;
use git::{
Expand Down Expand Up @@ -205,6 +206,19 @@ fn fetch(repo: String) -> AppResult<String> {
ops::fetch(&open(&repo)?)
}

/// Start watching a repo's git dir so external changes push a `repo-changed`
/// event to the UI. Idempotent per path.
#[tauri::command]
fn watch_repo(app: tauri::AppHandle, watchers: tauri::State<watch::Watchers>, repo: String) -> AppResult<()> {
watch::watch(&app, &watchers, &repo)
}

/// Stop watching a repo (its tab was closed).
#[tauri::command]
fn unwatch_repo(watchers: tauri::State<watch::Watchers>, repo: String) {
watch::unwatch(&watchers, &repo)
}

#[tauri::command]
fn merge(repo: String, branch: String) -> AppResult<String> {
ops::merge(&open(&repo)?, &branch)
Expand Down Expand Up @@ -479,7 +493,8 @@ pub fn run() {
let builder = tauri::Builder::default()
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_updater::Builder::new().build());
.plugin(tauri_plugin_updater::Builder::new().build())
.manage(watch::Watchers::default());

// macOS binds Cmd+W to the default Window menu's "Close Window". Replace the
// menu with just App + Edit (no Window menu) so Cmd+W is free for the JS
Expand Down Expand Up @@ -530,6 +545,8 @@ pub fn run() {
push_force,
pull,
fetch,
watch_repo,
unwatch_repo,
merge,
fast_forward_to,
rebase_onto,
Expand Down
Loading