@@ -13,6 +13,7 @@ def __init__(self, scene):
1313
1414 self .drawnCommits = {}
1515 self .drawnRefs = {}
16+ self .drawnCommitIds = {}
1617 self .commits = []
1718 self .zoomOuts = 0
1819 self .toFadeOut = m .Group ()
@@ -219,6 +220,9 @@ def draw_commit(
219220 )
220221 commitId .next_to (circle , m .UP )
221222
223+ if commit != "dark" :
224+ self .drawnCommitIds [commit .hexsha ] = commitId
225+
222226 message = m .Text (
223227 "\n " .join (
224228 commitMessage [j : j + 20 ] for j in range (0 , len (commitMessage ), 20 )
@@ -256,7 +260,11 @@ def build_commit_id_and_message(self, commit, dots=False):
256260 "" , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
257261 )
258262 commitMessage = ""
259- elif dots and commit .hexsha == self .commits [- 1 ].hexsha :
263+ elif (
264+ dots
265+ and self .commits [- 1 ] != "dark"
266+ and commit .hexsha == self .commits [- 1 ].hexsha
267+ ):
260268 commitId = m .Text (
261269 "..." , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
262270 )
@@ -297,13 +305,26 @@ def draw_head(self, commit, commitId):
297305
298306 def draw_branch (self , commit ):
299307 x = 0
300- branches = [branch .name for branch in self .repo .heads ]
308+
309+ remote_tracking_branches = self .get_remote_tracking_branches ()
310+
311+ branches = [branch .name for branch in self .repo .heads ] + list (
312+ remote_tracking_branches .keys ()
313+ )
314+
301315 for selected_branch in self .selected_branches :
302316 branches .insert (0 , branches .pop (branches .index (selected_branch )))
303317
304318 for branch in branches :
305-
306- if commit .hexsha == self .repo .heads [branch ].commit .hexsha :
319+ # Use forward slash to check if branch is local or remote tracking
320+ # and draw the branch label if its hexsha matches the current commit
321+ if (
322+ "/" not in branch # local branch
323+ and commit .hexsha == self .repo .heads [branch ].commit .hexsha
324+ ) or (
325+ "/" in branch # remote tracking branch
326+ and commit .hexsha == remote_tracking_branches [branch ]
327+ ):
307328 branchText = m .Text (
308329 branch , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
309330 )
@@ -924,6 +945,15 @@ def draw_dark_ref(self):
924945 def trim_path (self , path ):
925946 return (path [:5 ] + "..." + path [- 15 :]) if len (path ) > 20 else path
926947
948+ def get_remote_tracking_branches (self ):
949+ remote_refs = [remote .refs for remote in self .repo .remotes ]
950+ remote_tracking_branches = {}
951+ for reflist in remote_refs :
952+ for ref in reflist :
953+ if "HEAD" not in ref .name and ref .name not in remote_tracking_branches :
954+ remote_tracking_branches [ref .name ] = ref .commit .hexsha
955+ return remote_tracking_branches
956+
927957
928958class DottedLine (m .Line ):
929959 def __init__ (self , * args , dot_spacing = 0.4 , dot_kwargs = {}, ** kwargs ):
0 commit comments