Skip to content

unify Branch filtering#9118

Open
ajtmccarty wants to merge 2 commits intostablefrom
ajtm-05012026-unify-branch-get-list
Open

unify Branch filtering#9118
ajtmccarty wants to merge 2 commits intostablefrom
ajtm-05012026-unify-branch-get-list

Conversation

@ajtmccarty
Copy link
Copy Markdown
Contributor

consolidate the logic for filtering Branches: is_default, is_global, is in a terminal state

@ajtmccarty ajtmccarty requested a review from a team as a code owner May 1, 2026 20:42
@github-actions github-actions Bot added the group/backend Issue related to the backend (API Server, Git Agent) label May 1, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 1, 2026

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing ajtm-05012026-unify-branch-get-list (0cf6c68) with stable (9ab7bfb)1

Open in CodSpeed

Footnotes

  1. No successful run was found on stable (34251a9) during the generation of this report, so fb134fb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added some minor comments.

for b in await Branch.get_list(db=db)
if b.name not in [registry.default_branch, GLOBAL_BRANCH_NAME] and not b.is_terminal
]
branches = await Branch.get_list(db=db, exclude_global=True, exclude_default=True, exclude_terminal=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect Branch.get_list to always return a list and as such part of this function can be removed. Instead it becomes a one line function return await Branch.get_list(...

async def _get_other_active_branches(db: InfrahubDatabase) -> list[Branch]:
branches = await Branch.get_list(db=db)
return [branch for branch in branches if not (branch.is_global or branch.is_default or branch.is_terminal)]
return await Branch.get_list(db=db, exclude_global=True, exclude_default=True, exclude_terminal=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially consider this for later but this function is exactly the same as mark_branches_needing_rebase() from above. Since both should be one line functions I guess there's no huge harm. Just wondering how often they end up getting called.


branches = await Branch.get_list(db=db)
branches = [b for b in branches if not b.is_default and not b.is_global and not b.is_terminal]
branches = await Branch.get_list(db=db, exclude_global=True, exclude_default=True, exclude_terminal=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an example here we didn't choose to call one of those functions, which makes me wonder if there's a huge need for those functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group/backend Issue related to the backend (API Server, Git Agent)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants