git-machete icon indicating copy to clipboard operation
git-machete copied to clipboard

Tidy up `def status`

Open PawelLipski opened this issue 2 years ago • 0 comments

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 of utils.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 loop for branch, next_sibling_of_ancestor in next_sibling_of_ancestor_by_branch can probably go over self.managed_branches rather than over next_sibling_of_ancestor_by_branch

PawelLipski avatar Apr 30 '22 14:04 PawelLipski