Skip to content

Commit

Permalink
No longer add trailing space when annotation has no qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelLipski committed Jan 9, 2023
1 parent 3b895e2 commit cefda41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions git_machete/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ def __init__(self, text: str):
self.text_without_qualifiers = self.qualifiers.get_annotation_text_without_qualifiers()
self.qualifiers_text = self.qualifiers.get_qualifiers_text()

def get_unformatted_text(self) -> str:
annotation_text = f" {self.text_without_qualifiers}"
if self.qualifiers_text != '':
annotation_text += ' ' if self.text_without_qualifiers != '' else ''
annotation_text += self.qualifiers_text
return annotation_text

def get_formatted_text(self) -> str:
annotation_text = f" {utils.dim(self.text_without_qualifiers)}"
if self.qualifiers_text != '':
Expand Down
5 changes: 2 additions & 3 deletions git_machete/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,8 @@ def render_tree(self) -> List[str]:
self.__indent = "\t"

def render_dfs(branch: LocalBranchShortName, depth: int) -> List[str]:
self.annotation = f" {self.__annotations[branch].text_without_qualifiers} {self.__annotations[branch].qualifiers_text}" \
if branch in self.__annotations else ""
res: List[str] = [depth * self.__indent + branch + self.annotation]
annotation = self.__annotations[branch].get_unformatted_text() if branch in self.__annotations else ""
res: List[str] = [depth * self.__indent + branch + annotation]
for down_branch in self.__down_branches.get(branch, []):
res += render_dfs(down_branch, depth + 1)
return res
Expand Down

0 comments on commit cefda41

Please sign in to comment.