feat: add rename branch functionality with UI integration

This commit is contained in:
Bohdan Triapitsyn
2026-01-08 01:13:51 +02:00
parent d6f74087c4
commit 8902662f74
13 changed files with 284 additions and 3 deletions
@@ -1696,6 +1696,22 @@ pub async fn create_branch(
Ok(())
}
#[tauri::command]
pub async fn rename_branch(
directory: String,
old_name: String,
new_name: String,
state: State<'_, DesktopRuntime>,
) -> Result<(), String> {
let root = validate_git_path(&directory, state.settings())
.await
.map_err(|e| e.to_string())?;
run_git(&["branch", "-m", &old_name, &new_name], &root)
.await
.map_err(|e| e.to_string())?;
Ok(())
}
#[tauri::command]
pub async fn get_git_log(
directory: String,
+2 -1
View File
@@ -30,7 +30,7 @@ use axum::{
};
use commands::files::{create_directory, exec_commands, list_directory, read_file, search_files, write_file};
use commands::git::{
add_git_worktree, check_is_git_repository, checkout_branch, create_branch, create_git_commit,
add_git_worktree, check_is_git_repository, checkout_branch, create_branch, create_git_commit, rename_branch,
create_git_identity, delete_git_branch, delete_git_identity, delete_remote_branch,
ensure_openchamber_ignored, generate_commit_message, get_commit_files,
get_current_git_identity, get_git_branches, get_git_diff, get_git_file_diff,
@@ -863,6 +863,7 @@ fn main() {
git_fetch,
checkout_branch,
create_branch,
rename_branch,
get_git_log,
get_commit_files,
get_git_identities,
+9
View File
@@ -183,6 +183,15 @@ export const createDesktopGitAPI = (): GitAPI => ({
return { success: true, branch: name };
},
async renameBranch(directory: string, oldName: string, newName: string): Promise<{ success: boolean; branch: string }> {
await safeGitInvoke<void>('rename_branch', {
directory,
oldName,
newName
});
return { success: true, branch: newName };
},
async getGitLog(directory: string, options?: GitLogOptions): Promise<GitLogResponse> {
return safeGitInvoke<GitLogResponse>('get_git_log', {
directory,