migrate current branch to query pattern (#116)
This commit is contained in:
@@ -59,20 +59,14 @@ export function registerVersionHandlers() {
|
||||
});
|
||||
|
||||
if (!app) {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage: "App not found",
|
||||
};
|
||||
throw new Error("App not found");
|
||||
}
|
||||
|
||||
const appPath = getDyadAppPath(app.path);
|
||||
|
||||
// Return appropriate result if the app is not a git repo
|
||||
if (!fs.existsSync(path.join(appPath, ".git"))) {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage: "Not a git repository",
|
||||
};
|
||||
throw new Error("Not a git repository");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -83,17 +77,11 @@ export function registerVersionHandlers() {
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
branch: currentBranch || "<no-branch>",
|
||||
},
|
||||
branch: currentBranch || "<no-branch>",
|
||||
};
|
||||
} catch (error: any) {
|
||||
logger.error(`Error getting current branch for app ${appId}:`, error);
|
||||
return {
|
||||
success: false,
|
||||
errorMessage: `Failed to get current branch: ${error.message}`,
|
||||
};
|
||||
throw new Error(`Failed to get current branch: ${error.message}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -493,10 +493,9 @@ export class IpcClient {
|
||||
|
||||
// Get the current branch of an app
|
||||
public async getCurrentBranch(appId: number): Promise<BranchResult> {
|
||||
const result = await this.ipcRenderer.invoke("get-current-branch", {
|
||||
return this.ipcRenderer.invoke("get-current-branch", {
|
||||
appId,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// Get user settings
|
||||
|
||||
@@ -76,17 +76,7 @@ export interface Version {
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export type Result<T> =
|
||||
| {
|
||||
success: true;
|
||||
data: T;
|
||||
}
|
||||
| {
|
||||
success: false;
|
||||
errorMessage: string;
|
||||
};
|
||||
|
||||
export type BranchResult = Result<{ branch: string }>;
|
||||
export type BranchResult = { branch: string };
|
||||
|
||||
export interface SandboxConfig {
|
||||
files: Record<string, string>;
|
||||
|
||||
Reference in New Issue
Block a user