mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
fixes
This commit is contained in:
@@ -53,11 +53,36 @@ export function createListBranchesHandler() {
|
||||
isRemote: false,
|
||||
}));
|
||||
|
||||
// Get ahead/behind count for current branch
|
||||
let aheadCount = 0;
|
||||
let behindCount = 0;
|
||||
try {
|
||||
// First check if there's a remote tracking branch
|
||||
const { stdout: upstreamOutput } = await execAsync(
|
||||
`git rev-parse --abbrev-ref ${currentBranch}@{upstream}`,
|
||||
{ cwd: worktreePath }
|
||||
);
|
||||
|
||||
if (upstreamOutput.trim()) {
|
||||
const { stdout: aheadBehindOutput } = await execAsync(
|
||||
`git rev-list --left-right --count ${currentBranch}@{upstream}...HEAD`,
|
||||
{ cwd: worktreePath }
|
||||
);
|
||||
const [behind, ahead] = aheadBehindOutput.trim().split(/\s+/).map(Number);
|
||||
aheadCount = ahead || 0;
|
||||
behindCount = behind || 0;
|
||||
}
|
||||
} catch {
|
||||
// No upstream branch set, that's okay
|
||||
}
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
result: {
|
||||
currentBranch,
|
||||
branches,
|
||||
aheadCount,
|
||||
behindCount,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user