Skip to content

Commit 0793fc7

Browse files
Merge pull request #5 from rayburgemeestre/visualize-merges-better
Visualize child commits that are part of a merge commit
2 parents 4a029d6 + 85adbdf commit 0793fc7

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

bin/git-bc-show-eligible

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
from __future__ import unicode_literals
25

36
import subprocess
47
import argparse
@@ -96,10 +99,37 @@ if sys.stdout.isatty():
9699
author_format_str = ' \033[31m| %s <%s>\033[0m'
97100
commit_format_str = '\033[33m%s\033[0m %s%s'
98101

102+
seen = ''
103+
groups = []
104+
current_group = []
99105
for commit in find_unpicked(repo, from_commit, to_commit, since_commit, args.all):
100106
author_info = ''
101107
if args.all:
102108
author_info = author_format_str % (commit.author.name, commit.author.email)
103109

104-
print(commit_format_str % (str(commit.id), commit.message[:commit.message.index('\n')],
105-
author_info))
110+
commit_msg = commit.message[:commit.message.index('\n')]
111+
indent = commit_msg in seen
112+
seen += commit.message
113+
114+
commit_string = (commit_format_str % (str(commit.id), commit_msg, author_info))
115+
116+
if indent:
117+
current_group.append(commit_string)
118+
else:
119+
if current_group:
120+
groups.append(current_group)
121+
current_group = [commit_string]
122+
123+
for group in groups:
124+
merge = group[0]
125+
child_commits = group[1:-1]
126+
last_child_commit = group[-1] if len(group) > 1 else ''
127+
128+
print(merge)
129+
130+
for child in child_commits:
131+
print(" ├─ {}".format(child))
132+
133+
if last_child_commit:
134+
print(" └─ {}".format(last_child_commit))
135+

0 commit comments

Comments
 (0)