git-machete
git-machete copied to clipboard
Tidy up `def status`
The logic is pretty complicated, mostly due to the presence of the underlying DFS that collects the chain of next sibling for ancestor for each branch.
This DFS can stay... but a few suggestion on what could be refactored in the logic:
- no longer use ANSI escape code for anything but the final printing of status; in particular, the logic for
opt_list_commits
should not rely on comparing ANSI escape codes 😅 instead, use some more abstract representation of colors, to be mapped into either ANSI escape codes or its ASCII equivalents (in case ofutils.ascii_only
) - split into smaller methods
- naming of
prefix_dfs
and its local variables can be improved -
next_sibling_of_ancestor_by_branch
can be a dictionary rather than list of pairs; the main loopfor branch, next_sibling_of_ancestor in next_sibling_of_ancestor_by_branch
can probably go overself.managed_branches
rather than overnext_sibling_of_ancestor_by_branch