feat(title-bar): add folder-actions menu and branch dropdown with git operations
This commit is contained in:
@@ -2120,6 +2120,29 @@ pub async fn git_rebase(
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
|
||||
pub async fn git_delete_branch(
|
||||
path: String,
|
||||
branch_name: String,
|
||||
force: bool,
|
||||
) -> Result<String, AppCommandError> {
|
||||
let flag = if force { "-D" } else { "-d" };
|
||||
let output = crate::process::tokio_command("git")
|
||||
.args(["branch", flag, &branch_name])
|
||||
.current_dir(&path)
|
||||
.output()
|
||||
.await
|
||||
.map_err(AppCommandError::io)?;
|
||||
|
||||
if !output.status.success() {
|
||||
return Err(git_command_error(
|
||||
&format!("branch {flag}"),
|
||||
&output.stderr,
|
||||
));
|
||||
}
|
||||
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||
}
|
||||
|
||||
pub(crate) async fn git_delete_remote_branch_core(
|
||||
path: &str,
|
||||
remote: &str,
|
||||
|
||||
@@ -264,6 +264,7 @@ mod tauri_app {
|
||||
folders::git_set_remote_url,
|
||||
folders::git_merge,
|
||||
folders::git_rebase,
|
||||
folders::git_delete_branch,
|
||||
folders::git_delete_remote_branch,
|
||||
folders::git_list_conflicts,
|
||||
folders::git_conflict_file_versions,
|
||||
|
||||
@@ -450,6 +450,23 @@ pub async fn git_rebase(
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GitDeleteBranchParams {
|
||||
pub path: String,
|
||||
pub branch_name: String,
|
||||
pub force: bool,
|
||||
}
|
||||
|
||||
pub async fn git_delete_branch(
|
||||
Json(params): Json<GitDeleteBranchParams>,
|
||||
) -> Result<Json<String>, AppCommandError> {
|
||||
let result =
|
||||
folder_commands::git_delete_branch(params.path, params.branch_name, params.force)
|
||||
.await?;
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GitDeleteRemoteBranchParams {
|
||||
|
||||
@@ -243,6 +243,7 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
|
||||
.route("/git_fetch", post(handlers::git::git_fetch))
|
||||
.route("/git_commit", post(handlers::git::git_commit))
|
||||
.route("/git_fetch_remote", post(handlers::git::git_fetch_remote))
|
||||
.route("/git_delete_branch", post(handlers::git::git_delete_branch))
|
||||
.route(
|
||||
"/git_delete_remote_branch",
|
||||
post(handlers::git::git_delete_remote_branch),
|
||||
|
||||
Reference in New Issue
Block a user