fix: Close MR beads after successful merge from queue (#52)
The handleSuccessFromQueue function was missing critical steps that
exist in the legacy handleSuccess function:
1. Fetch and update the MR bead with merge_commit SHA and close_reason
2. Close the MR bead with CloseWithReason("merged", mr.ID)
Without these steps, the MR bead stayed "open" in beads even after the
queue file was deleted. This caused Mayor (which queries beads for open
merge-requests) to think there were pending MRs while Refinery (which
uses the queue) reported completion.
Fixes #46
This commit is contained in:
committed by
GitHub
parent
047585866a
commit
7f9795f630
@@ -486,6 +486,34 @@ func (e *Engineer) handleSuccessFromQueue(mr *mrqueue.MR, result ProcessResult)
|
||||
fmt.Fprintf(e.output, "[Engineer] Released merge slot\n")
|
||||
}
|
||||
|
||||
// Update and close the MR bead (matches handleSuccess behavior)
|
||||
if mr.ID != "" {
|
||||
// Fetch the MR bead to update its fields
|
||||
mrBead, err := e.beads.Show(mr.ID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(e.output, "[Engineer] Warning: failed to fetch MR bead %s: %v\n", mr.ID, err)
|
||||
} else {
|
||||
// Update MR with merge_commit SHA and close_reason
|
||||
mrFields := beads.ParseMRFields(mrBead)
|
||||
if mrFields == nil {
|
||||
mrFields = &beads.MRFields{}
|
||||
}
|
||||
mrFields.MergeCommit = result.MergeCommit
|
||||
mrFields.CloseReason = "merged"
|
||||
newDesc := beads.SetMRFields(mrBead, mrFields)
|
||||
if err := e.beads.Update(mr.ID, beads.UpdateOptions{Description: &newDesc}); err != nil {
|
||||
fmt.Fprintf(e.output, "[Engineer] Warning: failed to update MR %s with merge commit: %v\n", mr.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Close MR bead with reason 'merged'
|
||||
if err := e.beads.CloseWithReason("merged", mr.ID); err != nil {
|
||||
fmt.Fprintf(e.output, "[Engineer] Warning: failed to close MR %s: %v\n", mr.ID, err)
|
||||
} else {
|
||||
fmt.Fprintf(e.output, "[Engineer] Closed MR bead: %s\n", mr.ID)
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Close source issue with reference to MR
|
||||
if mr.SourceIssue != "" {
|
||||
closeReason := fmt.Sprintf("Merged in %s", mr.ID)
|
||||
|
||||
Reference in New Issue
Block a user