mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Modify git map-branches to show the number of commits on a branch
Currently, for a given branch, map-branches displays the number of commits ahead and behind it is. This change replaces ahead with commits, representing the number of commits a branch has, starting from its base commit, and more accurately reflects the state of a repo. Bug:1128716 Change-Id: I7c070b4efd452d82d878e1cfb7c20d1c80f38ec7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2412991 Commit-Queue: Gavin Mak <gavinmak@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
@@ -248,29 +248,30 @@ class BranchMapper(object):
|
||||
|
||||
# The branch tracking status.
|
||||
if self.verbosity >= 1:
|
||||
ahead_string = ''
|
||||
commits_string = ''
|
||||
behind_string = ''
|
||||
front_separator = ''
|
||||
center_separator = ''
|
||||
back_separator = ''
|
||||
if branch_info and not self.__is_invalid_parent(branch_info.upstream):
|
||||
ahead = branch_info.ahead
|
||||
behind = branch_info.behind
|
||||
commits = branch_info.commits
|
||||
|
||||
if ahead:
|
||||
ahead_string = 'ahead %d' % ahead
|
||||
if commits:
|
||||
commits_string = '%d commit' % commits
|
||||
commits_string += 's' if commits > 1 else ' '
|
||||
if behind:
|
||||
behind_string = 'behind %d' % behind
|
||||
|
||||
if ahead or behind:
|
||||
if commits or behind:
|
||||
front_separator = '['
|
||||
back_separator = ']'
|
||||
|
||||
if ahead and behind:
|
||||
if commits and behind:
|
||||
center_separator = '|'
|
||||
|
||||
line.append(front_separator, separator=' ')
|
||||
line.append(ahead_string, separator=' ', color=Fore.MAGENTA)
|
||||
line.append(commits_string, separator=' ', color=Fore.MAGENTA)
|
||||
line.append(center_separator, separator=' ')
|
||||
line.append(behind_string, separator=' ', color=Fore.MAGENTA)
|
||||
line.append(back_separator)
|
||||
|
||||
Reference in New Issue
Block a user