mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
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:
9 files changed
+225
-16
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user