Skip to content

Commit

Permalink
Fix color-by enum values
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Stopak <[email protected]>
  • Loading branch information
initialcommit-io committed Apr 21, 2023
1 parent 10b137e commit 3d5053a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions git_sim/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class StashSubCommand(Enum):


class ColorByOptions(Enum):
author = "author"
branch = "branch"
notlocal1 = "notlocal1"
notlocal2 = "notlocal2"
AUTHOR = "author"
BRANCH = "branch"
NOTLOCAL1 = "notlocal1"
NOTLOCAL2 = "notlocal2"


class StyleOptions(Enum):
Expand Down
8 changes: 4 additions & 4 deletions git_sim/git_sim_base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ def create_zone_text(
thirdColumnFilesDict[f] = text

def color_by(self, offset=0):
if settings.color_by == ColorByOptions.author:
if settings.color_by == ColorByOptions.AUTHOR:
sorted_authors = sorted(
self.author_groups.keys(),
key=lambda k: len(self.author_groups[k]),
Expand Down Expand Up @@ -1282,17 +1282,17 @@ def color_by(self, offset=0):
self.recenter_frame()
self.scale_frame()

elif settings.color_by == ColorByOptions.branch:
elif settings.color_by == ColorByOptions.BRANCH:
pass

elif settings.color_by == ColorByOptions.notlocal1:
elif settings.color_by == ColorByOptions.NOTLOCAL1:
for commit_id in self.drawnCommits:
try:
self.orig_repo.commit(commit_id)
except ValueError:
self.drawnCommits[commit_id].set_color(m.GOLD)

elif settings.color_by == ColorByOptions.notlocal2:
elif settings.color_by == ColorByOptions.NOTLOCAL2:
for commit_id in self.drawnCommits:
if not self.orig_repo.is_ancestor(commit_id, "HEAD"):
self.drawnCommits[commit_id].set_color(m.GOLD)
Expand Down
7 changes: 4 additions & 3 deletions git_sim/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from git_sim.git_sim_base_command import GitSimBaseCommand
from git_sim.settings import settings
from git_sim.enums import ColorByOptions


class Push(GitSimBaseCommand):
Expand Down Expand Up @@ -76,12 +77,12 @@ def construct(self):
push_result = 1
self.orig_repo = self.repo
self.repo = self.remote_repo
settings.color_by = "notlocal1"
settings.color_by = ColorByOptions.NOTLOCAL1
elif "rejected" in e.stderr and ("non-fast-forward" in e.stderr):
push_result = 2
self.orig_repo = self.repo
self.repo = self.remote_repo
settings.color_by = "notlocal2"
settings.color_by = ColorByOptions.NOTLOCAL2
else:
print(f"git-sim error: git push failed: {e.stderr}")
return
Expand Down Expand Up @@ -173,7 +174,7 @@ def failed_push(self, push_result):
text2.move_to(text1.get_center()).shift(m.DOWN / 2)

text3 = m.Text(
f"Gold commits exist are ahead of your current branch tip (need to be pulled).",
f"Gold commits are ahead of your current branch tip (need to be pulled).",
font="Monospace",
font_size=20,
color=m.GOLD,
Expand Down

0 comments on commit 3d5053a

Please sign in to comment.