diff --git a/bin/git-bc-show-eligible b/bin/git-bc-show-eligible index 795d469..b0d59e5 100755 --- a/bin/git-bc-show-eligible +++ b/bin/git-bc-show-eligible @@ -3,11 +3,12 @@ from __future__ import unicode_literals -import subprocess import argparse +import datetime import pygit2 -import sys import re +import subprocess +import sys def find_toplevel(): try: @@ -58,7 +59,10 @@ def main(): parser.add_argument('target_branch', metavar='TARGET_BRANCH', help='Name for the target branch', default='HEAD', nargs='?') parser.add_argument('--since', metavar='COMMIT', help='Start checking since specified commit') + parser.add_argument('--show-dates', action='store_true', help='Show dates in %Y-%m-%d %H:%M:%S') + parser.add_argument('--all', action='store_true', help='Show commits from all users') + parser.add_argument('--always-colors', action='store_true', help='Always force colored output') top = find_toplevel() @@ -96,7 +100,7 @@ def main(): author_format_str = ' | %s <%s>' commit_format_str = '%s %s%s' - if sys.stdout.isatty(): + if sys.stdout.isatty() or args.always_colors: author_format_str = ' \033[31m| %s <%s>\033[0m' commit_format_str = '\033[33m%s\033[0m %s%s' @@ -104,6 +108,14 @@ def main(): groups = [] current_group = [] for commit in find_unpicked(repo, from_commit, to_commit, since_commit, args.all): + formatted_date = '' + if args.show_dates: + timestamp = commit.commit_time # commit timestamp + offset = commit.commit_time_offset # timezone offset in minutes + commit_date = datetime.datetime.utcfromtimestamp(timestamp) + commit_date += datetime.timedelta(minutes=offset) + formatted_date = commit_date.strftime('%Y-%m-%d %H:%M:%S') + ' - ' + author_info = '' if args.all: author_info = author_format_str % (commit.author.name, commit.author.email) @@ -112,7 +124,7 @@ def main(): indent = commit_msg in seen seen += commit.message - commit_string = (commit_format_str % (str(commit.id), commit_msg, author_info)) + commit_string = formatted_date + (commit_format_str % (str(commit.id), commit_msg, author_info)) if indent: current_group.append(commit_string)