migrate current branch to query pattern (#116)

This commit is contained in:
Will Chen
2025-05-08 22:23:00 -07:00
committed by GitHub
parent 7839d6bde9
commit b6eeaab1bb
5 changed files with 65 additions and 77 deletions

View File

@@ -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}`);
}
},
);