feat(folder): add commit reset action in git log
Add a "Reset to Here" context action for git log commit items in the folder page. Show a reset dialog with branch, target commit, commit message, and reset mode details for soft, mixed, hard, and keep. Disable reset when viewing a non-current branch filter and keep the action ordering under commit diff. Add git_reset support across Rust commands, Tauri invoke registration, web handlers/routes, and frontend API/type bindings. Add localized reset labels, mode descriptions, and toast messages across all supported languages.
This commit is contained in:
@@ -1154,6 +1154,36 @@ pub async fn git_checkout(path: String, branch_name: String) -> Result<(), AppCo
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
|
||||
pub async fn git_reset(
|
||||
path: String,
|
||||
commit: String,
|
||||
mode: String,
|
||||
) -> Result<(), AppCommandError> {
|
||||
let mode = mode.trim().to_lowercase();
|
||||
let mode_flag = match mode.as_str() {
|
||||
"soft" | "mixed" | "hard" | "keep" => format!("--{mode}"),
|
||||
_ => {
|
||||
return Err(AppCommandError::invalid_input(
|
||||
"Reset mode must be one of: soft, mixed, hard, keep",
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
let output = crate::process::tokio_command("git")
|
||||
.args(["reset", mode_flag.as_str(), commit.as_str()])
|
||||
.current_dir(&path)
|
||||
.output()
|
||||
.await
|
||||
.map_err(AppCommandError::io)?;
|
||||
|
||||
if !output.status.success() {
|
||||
return Err(git_command_error("reset", &output.stderr));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
|
||||
pub async fn git_list_branches(path: String) -> Result<Vec<String>, AppCommandError> {
|
||||
let output = crate::process::tokio_command("git")
|
||||
|
||||
Reference in New Issue
Block a user