Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make branch prioritisation more general with a sorting function
Browse files Browse the repository at this point in the history
cvicentiu committed Nov 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent f5ca5a4 commit 04671c9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions utils.py
Original file line number Diff line number Diff line change
@@ -275,15 +275,19 @@ def fnmatch_any(branch: str, patterns: list[str]) -> bool:


# Priority filter based on saved package branches
def nextBuild(builder: Builder,
requests: list[BuildRequest]) -> str:
for r in requests:
if fnmatch_any(r.sources[""].branch, releaseBranches):
return r
for r in requests:
if fnmatch_any(r.sources[""].branch, savedPackageBranches):
return r
return requests[0]
def nextBuild(builder: Builder, requests: list[BuildRequest]) -> str:
def build_request_sort_key(request: BuildRequest):
branch = request.sources[""].branch
# Booleans are sorted False first.
# Priority is given to releaseBranches, savePackageBranches
# then it's first come, first serve.
return (
not fnmatch_any(branch, releaseBranches),
not fnmatch_any(branch, savedPackageBranches),
request.getSubmitTime(),
)

return sorted(requests, build_request_sort_key)[0]


def canStartBuild(

0 comments on commit 04671c9

Please sign in to comment.