From 85adbdf89cf83947cbd75b1fb68f056c459b6a72 Mon Sep 17 00:00:00 2001 From: Ray Burgemeestre Date: Thu, 25 Oct 2018 14:08:27 +0200 Subject: [PATCH] Visualize child commits that are part of a merge commit Thanks Luca for eXtreme Programming this one with me :) --- bin/git-bc-show-eligible | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/bin/git-bc-show-eligible b/bin/git-bc-show-eligible index 33d27c7..21ace6b 100755 --- a/bin/git-bc-show-eligible +++ b/bin/git-bc-show-eligible @@ -1,4 +1,7 @@ #!/usr/bin/env python +# coding=utf-8 + +from __future__ import unicode_literals import subprocess import argparse @@ -96,10 +99,37 @@ if sys.stdout.isatty(): author_format_str = ' \033[31m| %s <%s>\033[0m' commit_format_str = '\033[33m%s\033[0m %s%s' +seen = '' +groups = [] +current_group = [] for commit in find_unpicked(repo, from_commit, to_commit, since_commit, args.all): author_info = '' if args.all: author_info = author_format_str % (commit.author.name, commit.author.email) - print(commit_format_str % (str(commit.id), commit.message[:commit.message.index('\n')], - author_info)) + commit_msg = commit.message[:commit.message.index('\n')] + indent = commit_msg in seen + seen += commit.message + + commit_string = (commit_format_str % (str(commit.id), commit_msg, author_info)) + + if indent: + current_group.append(commit_string) + else: + if current_group: + groups.append(current_group) + current_group = [commit_string] + +for group in groups: + merge = group[0] + child_commits = group[1:-1] + last_child_commit = group[-1] if len(group) > 1 else '' + + print(merge) + + for child in child_commits: + print(" ├─ {}".format(child)) + + if last_child_commit: + print(" └─ {}".format(last_child_commit)) +