feat: add rename branch functionality with UI integration
This commit is contained in:
@@ -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>;
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
@@ -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 = {}
|
||||
|
||||
Reference in New Issue
Block a user