git map-branches: add --show-subject
BUG=
Review URL: https://codereview.chromium.org/996643004
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294578 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_map_branches.py b/git_map_branches.py
index 613abc7..96e6896 100755
--- a/git_map_branches.py
+++ b/git_map_branches.py
@@ -35,6 +35,7 @@
from git_common import current_branch, upstream, tags, get_branches_info
from git_common import get_git_version, MIN_UPSTREAM_TRACK_GIT_VERSION, hash_one
+from git_common import run
DEFAULT_SEPARATOR = ' ' * 4
@@ -110,6 +111,7 @@
def __init__(self):
self.verbosity = 0
self.maxjobs = 0
+ self.show_subject = False
self.output = OutputManager()
self.__gone_branches = set()
self.__branches_info = None
@@ -258,6 +260,10 @@
(url, color) = self.__status_info[branch]
line.append(url or none_text, color=color)
+ # The subject of the most recent commit on the branch.
+ if self.show_subject:
+ line.append(run('log', '-n1', '--format=%s', branch))
+
self.output.append(line)
for child in sorted(self.__parent_map.pop(branch, ())):
@@ -282,6 +288,8 @@
parser.add_argument(
'-j', '--maxjobs', action='store', type=int,
help='The number of jobs to use when retrieving review status')
+ parser.add_argument('--show-subject', action='store_true',
+ dest='show_subject', help='Show the commit subject.')
opts = parser.parse_args(argv)
@@ -289,6 +297,7 @@
mapper.verbosity = opts.v
mapper.output.nocolor = opts.nocolor
mapper.maxjobs = opts.maxjobs
+ mapper.show_subject = opts.show_subject
mapper.start()
print mapper.output.as_formatted_string()
return 0