@@ -13,6 +13,7 @@ def __init__(self, scene):
13
13
14
14
self .drawnCommits = {}
15
15
self .drawnRefs = {}
16
+ self .drawnCommitIds = {}
16
17
self .commits = []
17
18
self .zoomOuts = 0
18
19
self .toFadeOut = m .Group ()
@@ -219,6 +220,9 @@ def draw_commit(
219
220
)
220
221
commitId .next_to (circle , m .UP )
221
222
223
+ if commit != "dark" :
224
+ self .drawnCommitIds [commit .hexsha ] = commitId
225
+
222
226
message = m .Text (
223
227
"\n " .join (
224
228
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):
256
260
"" , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
257
261
)
258
262
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
+ ):
260
268
commitId = m .Text (
261
269
"..." , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
262
270
)
@@ -297,13 +305,26 @@ def draw_head(self, commit, commitId):
297
305
298
306
def draw_branch (self , commit ):
299
307
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
+
301
315
for selected_branch in self .selected_branches :
302
316
branches .insert (0 , branches .pop (branches .index (selected_branch )))
303
317
304
318
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
+ ):
307
328
branchText = m .Text (
308
329
branch , font = "Monospace" , font_size = 20 , color = self .scene .fontColor
309
330
)
@@ -924,6 +945,15 @@ def draw_dark_ref(self):
924
945
def trim_path (self , path ):
925
946
return (path [:5 ] + "..." + path [- 15 :]) if len (path ) > 20 else path
926
947
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
+
927
957
928
958
class DottedLine (m .Line ):
929
959
def __init__ (self , * args , dot_spacing = 0.4 , dot_kwargs = {}, ** kwargs ):
0 commit comments