fix: pr-closed-lookup (follow gh: find closed and merged pull requests by branch)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 18:57:43 +02:00
1 parent 9ce014bc75
commit 0db9ed463e
9 files changed
+225 -16

No files matched your search

+20
View File
@@ -276,6 +276,26 @@ func (s Pulls) ListOpen(ctx context.Context) ([]Pull, error) {
})
}
// NewestClosed returns the most recently updated closed or merged pull request that keep
// accepts, and whether there is one. It reads pages newest first and stops at the first match.
func (s Pulls) NewestClosed(ctx context.Context, keep func(Pull) bool) (Pull, bool, error) {
for page := 1; page <= maxListPages; page++ {
items, _, err := s.List(ctx, PullListOptions{State: "closed", Sort: "recentupdate", Limit: 50, Page: page})
if err != nil {
return Pull{}, false, err
}
if len(items) == 0 {
return Pull{}, false, nil
}
for _, item := range items {
if keep(item) {
return item, true, nil
}
}
}
return Pull{}, false, nil
}
// Create opens a pull request.
func (s Pulls) Create(ctx context.Context, opts PullOptions) (Pull, error) {
// TODO(sdk): CreatePullRequestOption lacks allow_maintainer_edit.