diff options
| author | Mica White <botahamec@outlook.com> | 2026-03-30 20:59:30 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-03-30 20:59:30 -0400 |
| commit | e5692c42d3f2323cba6f10a4fc1e98b60507df51 (patch) | |
| tree | 2195ed8c8845ff46de2c849feea00ae80eaf132b | |
| parent | 0e82b20e196206d020f2111da4b3cce4d8682e42 (diff) | |
Check repo status before autosaving
| -rw-r--r-- | src/bin/git-autosave-daemon.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/git-autosave-daemon.rs b/src/bin/git-autosave-daemon.rs index a0066a5..39df4b8 100644 --- a/src/bin/git-autosave-daemon.rs +++ b/src/bin/git-autosave-daemon.rs @@ -2,7 +2,7 @@ use std::{collections::HashSet, time::Duration}; use auth_git2::GitAuthenticator; use git_autosave::{Config, authenticate::Inquirer, commit_autosave, push_autosaves}; -use git2::{RemoteCallbacks, Repository}; +use git2::{RemoteCallbacks, Repository, StatusOptions}; use happylock::{Mutex, ThreadKey}; use notify::{EventKind, INotifyWatcher, RecursiveMode}; use notify_debouncer_full::{ @@ -126,6 +126,14 @@ impl DebounceEventHandler for Watcher { if workdirs_to_autosave.contains(workdir) { continue; } + if let Ok(status) = repository.statuses(Some( + StatusOptions::new() + .include_untracked(true) + .include_ignored(false), + )) && status.is_empty() + { + continue; + } log::info!("Updated path: {:?}", &path); workdirs_to_autosave.insert(workdir.to_path_buf()); |
