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
+1
View File
@@ -281,6 +281,7 @@ export interface GitAPI {
gitFetch(directory: string, options?: { remote?: string; branch?: string }): Promise<{ success: boolean }>;
checkoutBranch(directory: string, branch: string): Promise<{ success: boolean; branch: string }>;
createBranch(directory: string, name: string, startPoint?: string): Promise<{ success: boolean; branch: string }>;
renameBranch(directory: string, oldName: string, newName: string): Promise<{ success: boolean; branch: string }>;
getGitLog(directory: string, options?: GitLogOptions): Promise<GitLogResponse>;
getCommitFiles(directory: string, hash: string): Promise<GitCommitFilesResponse>;
getCurrentGitIdentity(directory: string): Promise<GitIdentitySummary | null>;
+10
View File
@@ -179,6 +179,16 @@ export async function createBranch(
return gitHttp.createBranch(directory, name, startPoint);
}
export async function renameBranch(
directory: string,
oldName: string,
newName: string
): Promise<{ success: boolean; branch: string }> {
const runtime = getRuntimeGit();
if (runtime) return runtime.renameBranch(directory, oldName, newName);
return gitHttp.renameBranch(directory, oldName, newName);
}
export async function getGitLog(
directory: string,
options: import('./api/types').GitLogOptions = {}
+17
View File
@@ -404,6 +404,23 @@ export async function createBranch(
return response.json();
}
export async function renameBranch(
directory: string,
oldName: string,
newName: string
): Promise<{ success: boolean; branch: string }> {
const response = await fetch(buildUrl(`${API_BASE}/branches/rename`, directory), {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ oldName, newName }),
});
if (!response.ok) {
const error = await response.json().catch(() => ({ error: response.statusText }));
throw new Error(error.error || 'Failed to rename branch');
}
return response.json();
}
export async function getGitLog(
directory: string,
options: GitLogOptions = {}