fix: Roll back merge when push fails in initiative approval
When merge_and_push failed at the push step, the local defaultBranch ref was left pointing at the merge commit. This made the three-dot diff (defaultBranch...initiativeBranch) return empty because main already contained all changes — causing the review tab to show "no changes." Now mergeBranch returns the previous ref, and approveInitiative restores it on push failure. Also repaired the corrupted clone state.
This commit is contained in:
@@ -695,7 +695,18 @@ export class ExecutionOrchestrator {
|
||||
if (!result.success) {
|
||||
throw new Error(`Failed to merge ${initiative.branch} into ${project.defaultBranch} for project ${project.name}: ${result.message}`);
|
||||
}
|
||||
await this.branchManager.pushBranch(clonePath, project.defaultBranch);
|
||||
try {
|
||||
await this.branchManager.pushBranch(clonePath, project.defaultBranch);
|
||||
} catch (pushErr) {
|
||||
// Roll back the merge so the diff doesn't disappear from the review tab.
|
||||
// Without rollback, defaultBranch includes the initiative changes and the
|
||||
// three-dot diff (defaultBranch...initiativeBranch) becomes empty.
|
||||
if (result.previousRef) {
|
||||
log.warn({ project: project.name, previousRef: result.previousRef }, 'push failed — rolling back merge');
|
||||
await this.branchManager.updateRef(clonePath, project.defaultBranch, result.previousRef);
|
||||
}
|
||||
throw pushErr;
|
||||
}
|
||||
log.info({ initiativeId, project: project.name }, 'initiative branch merged into default and pushed');
|
||||
} else {
|
||||
await this.branchManager.pushBranch(clonePath, initiative.branch);
|
||||
|
||||
Reference in New Issue
Block a user