@@ -101,7 +101,9 @@ def construct(self):
101101 self .show_outro ()
102102
103103 def get_commit (self , sha_or_ref = "HEAD" ):
104- return self .repo .commit (sha_or_ref )
104+ if self .head_exists ():
105+ return self .repo .commit (sha_or_ref )
106+ return "dark"
105107
106108 def get_default_commits (self ):
107109 defaultCommits = [self .get_commit ()]
@@ -646,7 +648,9 @@ def setup_and_draw_zones(
646648 reverse = False ,
647649 ):
648650 if self .check_all_dark ():
649- self .zone_title_offset = 2.0 if platform .system () == "Windows" else 6.0
651+ self .zone_title_offset = 2.0 if platform .system () == "Windows" else 2.0
652+ elif len (self .drawnCommits ) == 1 :
653+ self .zone_title_offset = 2.0 if platform .system () == "Windows" else 2.0
650654
651655 horizontal = m .Line (
652656 (
@@ -928,6 +932,9 @@ def populate_zones(
928932 firstColumnFileNames .add (z )
929933
930934 def center_frame_on_commit (self , commit ):
935+ if not commit or commit == "dark" :
936+ return
937+
931938 if settings .animate :
932939 self .play (
933940 self .camera .frame .animate .move_to (
@@ -938,6 +945,9 @@ def center_frame_on_commit(self, commit):
938945 self .camera .frame .move_to (self .drawnCommits [commit .hexsha ].get_center ())
939946
940947 def reset_head_branch (self , hexsha , shift = numpy .array ([0.0 , 0.0 , 0.0 ])):
948+ if not self .head_exists ():
949+ return
950+
941951 if settings .animate :
942952 self .play (
943953 self .drawnRefs ["HEAD" ].animate .move_to (
@@ -1046,25 +1056,28 @@ def setup_and_draw_parent(
10461056 fill_opacity = self .ref_fill_opacity ,
10471057 )
10481058 circle .height = 1
1049- circle .next_to (
1050- self .drawnCommits [child .hexsha ],
1051- m .LEFT if settings .reverse else m .RIGHT ,
1052- buff = 1.5 ,
1053- )
1059+ if child != "dark" :
1060+ circle .next_to (
1061+ self .drawnCommits [child .hexsha ],
1062+ m .LEFT if settings .reverse else m .RIGHT ,
1063+ buff = 1.5 ,
1064+ )
1065+
10541066 circle .shift (shift )
10551067
1056- start = circle .get_center ()
1057- end = self .drawnCommits [child .hexsha ].get_center ()
1058- arrow = m .Arrow (
1059- start ,
1060- end ,
1061- color = self .fontColor ,
1062- stroke_width = self .arrow_stroke_width ,
1063- tip_shape = self .arrow_tip_shape ,
1064- max_stroke_width_to_length_ratio = 1000 ,
1065- )
1066- length = numpy .linalg .norm (start - end ) - (1.5 if start [1 ] == end [1 ] else 3 )
1067- arrow .set_length (length )
1068+ if child != "dark" :
1069+ start = circle .get_center ()
1070+ end = self .drawnCommits [child .hexsha ].get_center ()
1071+ arrow = m .Arrow (
1072+ start ,
1073+ end ,
1074+ color = self .fontColor ,
1075+ stroke_width = self .arrow_stroke_width ,
1076+ tip_shape = self .arrow_tip_shape ,
1077+ max_stroke_width_to_length_ratio = 1000 ,
1078+ )
1079+ length = numpy .linalg .norm (start - end ) - (1.5 if start [1 ] == end [1 ] else 3 )
1080+ arrow .set_length (length )
10681081
10691082 commitId = m .Text (
10701083 "abcdef" ,
@@ -1102,7 +1115,7 @@ def setup_and_draw_parent(
11021115 self .drawnCommits ["abcdef" ] = circle
11031116 self .toFadeOut .add (circle )
11041117
1105- if draw_arrow :
1118+ if draw_arrow and child != "dark" :
11061119 if settings .animate :
11071120 self .play (m .Create (arrow ), run_time = 1 / settings .speed )
11081121 else :
0 commit comments