unify Branch filtering#9118
Conversation
ogenstad
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
consolidate the logic for filtering Branches: is_default, is_global, is in a terminal state