Skip to content

Commit e3afcc8

Browse files
Add global flags for --invert-branches and --hide-merged-chains
Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
1 parent 7564b67 commit e3afcc8

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ The `[global options]` apply to the overarching `git-sim` simulation itself, inc
139139
`-d`: Disable the automatic opening of the image/video file after generation. Useful to avoid errors in console mode with no GUI.
140140
`--reverse, -r`: Display commit history in the reverse direction.
141141
`--img-format`: Output format for the image file, i.e. `jpg` or `png`. Default output format is `jpg`.
142-
`--stdout`: Write raw image data to stdout while suppressing all other program output.
142+
`--stdout`: Write raw image data to stdout while suppressing all other program output.
143+
`--invert-branches`: Invert positioning of branches by reversing order of multiple parents where applicable.
144+
`--hide-merged-chains`: Hide commits from merged branches, i.e. only display mainline commits.
143145

144146
Animation-only global options (to be used in conjunction with `--animate`):
145147

git_sim/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ def main(
107107
settings.stdout,
108108
help="Write raw image data to stdout while suppressing all other program output",
109109
),
110+
invert_branches: bool = typer.Option(
111+
settings.invert_branches,
112+
help="Invert positioning of branches by reversing order of multiple parents where applicable",
113+
),
114+
hide_merged_chains: bool = typer.Option(
115+
settings.hide_merged_chains,
116+
help="Hide commits from merged branches, i.e. only display mainline commits",
117+
),
110118
):
111119
settings.animate = animate
112120
settings.auto_open = auto_open
@@ -126,6 +134,8 @@ def main(
126134
settings.title = title
127135
settings.video_format = video_format
128136
settings.stdout = stdout
137+
settings.invert_branches = invert_branches
138+
settings.hide_merged_chains = hide_merged_chains
129139

130140
if sys.platform == "linux" or sys.platform == "darwin":
131141
repo_name = git.repo.Repo(

git_sim/log.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ def parse_commits(
7373
i += 1
7474
commitParents = list(commit.parents)
7575
if len(commitParents) > 0:
76-
# if ( self.args.invert_branches ):
77-
# commitParents.reverse()
78-
79-
# if ( self.args.hide_merged_chains ):
80-
# self.parseCommits(commitParents[0], i+1, prevCircle, toFadeOut)
81-
# else:
82-
for p in range(len(commitParents)):
83-
self.parse_commits(commitParents[p], i, circle)
76+
if settings.invert_branches:
77+
commitParents.reverse()
78+
79+
if settings.hide_merged_chains:
80+
self.parse_commits(commitParents[0], i, circle)
81+
else:
82+
for p in range(len(commitParents)):
83+
self.parse_commits(commitParents[p], i, circle)
8484

8585
def draw_commit(self, commit, prevCircle, shift=numpy.array([0.0, 0.0, 0.0])):
8686
if commit == "dark":

git_sim/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Settings(BaseSettings):
3939
title = "Git-Sim, by initialcommit.com"
4040
video_format: VideoFormat = VideoFormat.mp4
4141
stdout = False
42+
invert_branches = False
43+
hide_merged_chains = False
4244

4345
class Config:
4446
env_prefix = "git_sim_"

0 commit comments

Comments
 (0)