Update dependencies and implement git-based sync direction defaults

- Updated `clap` and `unicode-ident` versions in `Cargo.lock` and `Cargo.toml`.
- Added `sha1` crate to `Cargo.toml` for SHA1 hashing functionality.
- Introduced a new `git.rs` module for handling git operations, including changed files and SHA1 computation.
- Enhanced the sync confirmation dialog to auto-select defaults based on git status, improving user experience during two-way sync.
- Updated `PatchTree` to utilize git metadata for determining default selections during patch application.

These changes enhance the integration with git, providing smarter defaults and improving the overall sync process.
This commit is contained in:
Joe 2026-02-17 20:36:28 -06:00
parent df22500102
commit 7ba04f7f6a
29 changed files with 1285 additions and 176 deletions

View file

@ -2,6 +2,7 @@ use crossbeam_channel::{select, Receiver, RecvError, Sender};
use jod_thread::JoinHandle;
use memofs::{IoResultExt, Vfs, VfsEvent};
use rbx_dom_weak::types::{Ref, Variant};
use std::collections::HashSet;
use std::fmt;
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};
@ -83,6 +84,7 @@ impl ChangeProcessor {
ref_path_index: Arc<Mutex<crate::RefPathIndex>>,
project_root: PathBuf,
critical_error_receiver: Option<Receiver<memofs::WatcherCriticalError>>,
git_repo_root: Option<PathBuf>,
) -> Self {
let (shutdown_sender, shutdown_receiver) = crossbeam_channel::bounded(1);
let vfs_receiver = vfs.event_receiver();
@ -101,6 +103,7 @@ impl ChangeProcessor {
suppressed_paths,
project_root,
ref_path_index,
git_repo_root,
};
let job_thread = jod_thread::Builder::new()
@ -245,6 +248,10 @@ struct JobThreadContext {
/// Index of meta/model files that contain `Rojo_Ref_*` attributes.
/// Shared with ApiService for efficient rename path updates.
ref_path_index: Arc<Mutex<crate::RefPathIndex>>,
/// Git repository root, if the project is in a git repo.
/// Used for auto-staging Source writes.
git_repo_root: Option<PathBuf>,
}
impl JobThreadContext {
@ -1005,6 +1012,7 @@ impl JobThreadContext {
added_instances: patch_set.added_instances,
removed_instances: patch_set.removed_instances,
updated_instances: Vec::new(),
stage_ids: HashSet::new(),
};
let applied = apply_patch_set(&mut tree, structural_patch);
@ -1812,6 +1820,10 @@ impl JobThreadContext {
id,
err
);
} else if patch_set.stage_ids.contains(&id) {
if let Some(ref repo_root) = self.git_repo_root {
crate::git::git_add(repo_root, std::slice::from_ref(write_path));
}
}
} else {
log::warn!("Cannot change Source to non-string value.");