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

@ -264,8 +264,7 @@ impl ApiService {
/// Get a summary of information about the server
async fn handle_api_rojo(&self) -> Response<Full<Bytes>> {
let tree = self.serve_session.tree();
let root_instance_id = tree.get_root_id();
let root_instance_id = self.serve_session.tree().get_root_id();
let ignore_hidden_services = self.serve_session.ignore_hidden_services();
let visible_services = if ignore_hidden_services {
@ -274,6 +273,11 @@ impl ApiService {
Vec::new()
};
let git_metadata = crate::git::compute_git_metadata(
&self.serve_session.tree_handle(),
self.serve_session.root_dir(),
);
msgpack_ok(&ServerInfoResponse {
server_version: SERVER_VERSION.to_owned(),
protocol_version: PROTOCOL_VERSION,
@ -288,6 +292,7 @@ impl ApiService {
sync_source_only: true,
ignore_hidden_services,
visible_services,
git_metadata,
})
}
@ -735,14 +740,38 @@ impl ApiService {
})
.collect();
let stage_ids: HashSet<Ref> = request.stage_ids.into_iter().collect();
tree_mutation_sender
.send(PatchSet {
removed_instances: actually_removed,
added_instances,
updated_instances,
stage_ids: stage_ids.clone(),
})
.unwrap();
if let Some(repo_root) = self.serve_session.git_repo_root() {
if !stage_ids.is_empty() {
let tree = self.serve_session.tree();
let paths_to_stage: Vec<PathBuf> = stage_ids
.iter()
.filter_map(|&id| {
tree.get_instance(id).and_then(|inst| {
inst.metadata().instigating_source.as_ref().map(|src| {
src.path().to_path_buf()
})
})
})
.collect();
drop(tree);
if !paths_to_stage.is_empty() {
crate::git::git_add(repo_root, &paths_to_stage);
}
}
}
msgpack_ok(WriteResponse { session_id })
}