feat(remote): Enhance remote branch management and stability
Improved handling for deleting remote branches across the application, enhancing both user experience and backend reliability. This includes adding structured logging to all Git remote operations in Rust, refining UI components to handle remote-specific deletion flows, and providing clear status/error feedback in sync settings. - Standardized styling for action toggles (Stash, Branch, Explorer) using consistent dimensions. - Implemented detailed console logging for all Git remote operations on the backend. - Refined dialogs and sync settings to provide explicit status and error messages during remote management.
This commit is contained in:
+35
-12
@@ -493,6 +493,7 @@ pub fn list_branches(path: String) -> Result<Vec<GitBranch>, String> {
|
||||
|
||||
#[tauri::command]
|
||||
pub fn list_remotes(path: String) -> Result<Vec<GitRemote>, String> {
|
||||
log::info!(target: "gitty::remote", "list_remotes invoked: path={path:?}");
|
||||
let repo = resolve_repo(&path)?;
|
||||
let names = run_git(&repo, ["remote"])?;
|
||||
Ok(String::from_utf8_lossy(&names)
|
||||
@@ -531,10 +532,23 @@ pub fn update_remote(path: String, name: String, url: String) -> Result<Vec<GitR
|
||||
|
||||
#[tauri::command]
|
||||
pub fn remove_remote(path: String, name: String) -> Result<Vec<GitRemote>, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let name = validate_remote_name(&repo, &name, true)?;
|
||||
run_git(&repo, ["remote", "remove", name.as_str()])?;
|
||||
list_remotes(path)
|
||||
log::info!(target: "gitty::remote", "remove_remote invoked: path={path:?}, name={name:?}");
|
||||
let result = (|| {
|
||||
let repo = resolve_repo(&path)?;
|
||||
log::info!(target: "gitty::remote", "remove_remote resolved repository: {}", repo.display());
|
||||
let name = validate_remote_name(&repo, &name, true)?;
|
||||
log::info!(target: "gitty::remote", "remove_remote validated remote: {name}");
|
||||
run_git(&repo, ["remote", "remove", name.as_str()])?;
|
||||
log::info!(target: "gitty::remote", "remove_remote git command succeeded: {name}");
|
||||
list_remotes(path)
|
||||
})();
|
||||
match &result {
|
||||
Ok(remotes) => {
|
||||
log::info!(target: "gitty::remote", "remove_remote completed; remaining={:?}", remotes.iter().map(|remote| remote.name.as_str()).collect::<Vec<_>>())
|
||||
}
|
||||
Err(error) => log::error!(target: "gitty::remote", "remove_remote failed: {error}"),
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
@@ -576,15 +590,24 @@ pub fn delete_remote_branch(
|
||||
remote: String,
|
||||
branch: String,
|
||||
) -> Result<GitStatus, String> {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let remote = validate_remote_name(&repo, &remote, true)?;
|
||||
let branch = branch.trim();
|
||||
if branch.is_empty() || branch.starts_with('-') {
|
||||
return Err("Invalid remote branch name.".to_string());
|
||||
log::info!(target: "gitty::remote", "delete_remote_branch invoked: path={path:?}, remote={remote:?}, branch={branch:?}");
|
||||
let result = (|| {
|
||||
let repo = resolve_repo(&path)?;
|
||||
let remote = validate_remote_name(&repo, &remote, true)?;
|
||||
let branch = branch.trim();
|
||||
if branch.is_empty() || branch.starts_with('-') {
|
||||
return Err("Invalid remote branch name.".to_string());
|
||||
}
|
||||
run_git(&repo, ["check-ref-format", "--branch", branch])?;
|
||||
log::info!(target: "gitty::remote", "deleting remote branch with git push: {remote}/{branch}");
|
||||
run_git(&repo, ["push", remote.as_str(), "--delete", branch])?;
|
||||
log::info!(target: "gitty::remote", "remote branch deleted successfully: {remote}/{branch}");
|
||||
status_for_repo(&repo)
|
||||
})();
|
||||
if let Err(error) = &result {
|
||||
log::error!(target: "gitty::remote", "delete_remote_branch failed: {error}");
|
||||
}
|
||||
run_git(&repo, ["check-ref-format", "--branch", branch])?;
|
||||
run_git(&repo, ["push", remote.as_str(), "--delete", branch])?;
|
||||
status_for_repo(&repo)
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user