Files
archie/internal/forge/merge.go
T
sam 5edf58fd68 fix(daemon): reconcile and merge tasks whose PR was merged on the forge (#1872)
ListOpenPRs dropped org_id, so the reconciler resolved the forge and
worktrees in the default org instead of the task's own and skipped the
task silently. Select the org, log a skipped task, and let the Merge
action succeed when the forge reports the PR already merged.
2026-11-14 04:01:31 +11:00

25 lines
685 B
Go

package forge
import (
"context"
"errors"
)
// PRStateMerged is the state PRState reports for a merged pull request.
const PRStateMerged = "merged"
// MergeOrConfirm merges a pull request and treats a refusal as success when
// the forge reports the PR already merged: a merge outside Archie, or one that
// raced the reconciler, leaves nothing to refuse.
func MergeOrConfirm(ctx context.Context, f Forge, owner, repo string, number int) error {
mergeErr := f.MergePR(ctx, owner, repo, number)
if mergeErr == nil {
return nil
}
state, err := f.PRState(ctx, owner, repo, number)
if err == nil && state == PRStateMerged {
return nil
}
return errors.Join(mergeErr, err)
}