88
99
1010class Log (GitSimBaseCommand ):
11- def __init__ (self , commits : int ):
11+ def __init__ (self , commits : int , all : bool ):
1212 super ().__init__ ()
1313 self .numCommits = commits + 1
1414 self .defaultNumCommits = commits + 1
@@ -17,13 +17,18 @@ def __init__(self, commits: int):
1717 except TypeError :
1818 pass
1919 self .arrow_map = []
20+ self .all = all
2021
2122 def construct (self ):
2223 if not settings .stdout :
2324 print (f"{ settings .INFO_STRING } { type (self ).__name__ .lower ()} " )
2425 self .show_intro ()
2526 self .get_commits ()
2627 self .parse_commits (self .commits [0 ], 0 )
28+ if self .all :
29+ for branch in self .repo .branches :
30+ self .get_commits (start = branch .name )
31+ self .parse_commits (self .commits [0 ], 0 )
2732 self .recenter_frame ()
2833 self .scale_frame ()
2934 self .fadeout ()
@@ -44,9 +49,21 @@ def parse_commits(
4449 self .draw_head (commit , commitId )
4550 self .draw_branch (commit )
4651 self .draw_tag (commit )
47- if [arrow .start .tolist (), arrow .end .tolist ()] not in self .arrow_map :
52+ if (
53+ not isinstance (arrow , m .CurvedArrow )
54+ and [arrow .start .tolist (), arrow .end .tolist ()] not in self .arrow_map
55+ ):
4856 self .draw_arrow (prevCircle , arrow )
4957 self .arrow_map .append ([arrow .start .tolist (), arrow .end .tolist ()])
58+ elif (
59+ isinstance (arrow , m .CurvedArrow )
60+ and [arrow .get_start ().tolist (), arrow .get_end ().tolist ()]
61+ not in self .arrow_map
62+ ):
63+ self .draw_arrow (prevCircle , arrow )
64+ self .arrow_map .append (
65+ [arrow .get_start ().tolist (), arrow .get_end ().tolist ()]
66+ )
5067 if i == 0 and len (self .drawnRefs ) < 2 :
5168 self .draw_dark_ref ()
5269
@@ -102,7 +119,11 @@ def draw_commit(
102119 end = circle .get_center ()
103120 else :
104121 circle .move_to (self .drawnCommits [commit .hexsha ].get_center ())
105- start = prevCircle .get_center ()
122+ start = (
123+ prevCircle .get_center ()
124+ if prevCircle
125+ else (m .LEFT if settings .reverse else m .RIGHT )
126+ )
106127 end = self .drawnCommits [commit .hexsha ].get_center ()
107128
108129 arrow = m .Arrow (start , end , color = self .fontColor )
@@ -126,9 +147,9 @@ def draw_commit(
126147 if inter .has_points ():
127148 arrow = m .CurvedArrow (start , end )
128149 if start [1 ] == end [1 ]:
129- arrow .shift (UP * 1.25 )
150+ arrow .shift (m . UP * 1.25 )
130151 if start [0 ] < end [0 ] and start [1 ] == end [1 ]:
131- arrow .flip (RIGHT ).shift (UP )
152+ arrow .flip (m . RIGHT ).shift (m . UP )
132153
133154 commitId , commitMessage , commit , hide_refs = self .build_commit_id_and_message (
134155 commit , dots
@@ -175,6 +196,10 @@ def log(
175196 help = "The number of commits to display in the simulated log output" ,
176197 min = 1 ,
177198 ),
199+ all : bool = typer .Option (
200+ default = False ,
201+ help = "Display all local branches in the log output" ,
202+ ),
178203):
179- scene = Log (commits = commits )
204+ scene = Log (commits = commits , all = all )
180205 handle_animations (scene = scene )
0 commit comments