Merge complete loop (#37018)

* prevent merge complete loop

* dependency
This commit is contained in:
Saxon Fletcher authored and GitHub committed 2025-07-10 20:33:49 +08:00
1 parent 6504a8460f
commit 53cd3e44a7
1 file changed
+45 -26
+45 -26
View File
@@ -103,39 +103,67 @@ const MergePage: NextPageWithLayout = () => {
currentBranchCreatedAt: currentBranch?.created_at,
})
const { mutate: updateBranch } = useBranchUpdateMutation({
onSuccess: () => {
toast.success('Branch updated successfully')
},
onError: (error) => {
toast.error(`Failed to update branch: ${error.message}`)
},
})
const clearDiffsOptimistically = edgeFunctionsDiff.clearDiffsOptimistically
const currentWorkflowRunId = router.query.workflow_run_id as string | undefined
useEffect(() => {
setWorkflowFinalStatus(null)
}, [currentWorkflowRunId])
const handleCurrentBranchWorkflowComplete = useCallback(
(status: string) => {
setWorkflowFinalStatus(status)
refetchDiff()
clearDiffsOptimistically()
},
[refetchDiff, clearDiffsOptimistically]
)
const handleParentBranchWorkflowComplete = useCallback(
(status: string) => {
setWorkflowFinalStatus(status)
refetchDiff()
clearDiffsOptimistically()
if (parentProjectRef && currentBranch?.id && currentBranch.review_requested_at) {
updateBranch({
id: currentBranch.id,
projectRef: parentProjectRef,
requestReview: false,
})
}
},
[
refetchDiff,
clearDiffsOptimistically,
parentProjectRef,
currentBranch?.id,
updateBranch,
currentBranch?.review_requested_at,
]
)
const { currentWorkflowRun: currentBranchWorkflow, workflowRunLogs: currentBranchLogs } =
useWorkflowManagement({
workflowRunId: currentWorkflowRunId,
projectRef: ref,
onWorkflowComplete: (status) => {
setWorkflowFinalStatus(status)
refetchDiff()
edgeFunctionsDiff.clearDiffsOptimistically()
},
onWorkflowComplete: handleCurrentBranchWorkflowComplete,
})
const { currentWorkflowRun: parentBranchWorkflow, workflowRunLogs: parentBranchLogs } =
useWorkflowManagement({
workflowRunId: currentWorkflowRunId,
projectRef: parentProjectRef,
onWorkflowComplete: (status) => {
setWorkflowFinalStatus(status)
refetchDiff()
edgeFunctionsDiff.clearDiffsOptimistically()
if (parentProjectRef && currentBranch?.id) {
updateBranch({
id: currentBranch.id,
projectRef: parentProjectRef,
requestReview: false,
})
}
},
onWorkflowComplete: handleParentBranchWorkflowComplete,
})
const currentWorkflowRun = currentBranchWorkflow || parentBranchWorkflow
@@ -210,15 +238,6 @@ const MergePage: NextPageWithLayout = () => {
},
})
const { mutate: updateBranch } = useBranchUpdateMutation({
onSuccess: () => {
toast.success('Branch updated successfully')
},
onError: (error) => {
toast.error(`Failed to update branch: ${error.message}`)
},
})
const handlePush = () => {
if (!currentBranch?.id || !parentProjectRef) return
pushBranch({