Commit 6e269a0b authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Extend git-cl-owners to show all owners for a file

Change-Id: Ie1109c3da9c687a9543c0cfb91f8660c29fb36c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1664391
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent d9ae3342
......@@ -5367,6 +5367,12 @@ def CMDowners(parser, args):
'--batch',
action='store_true',
help='Do not run interactively, just suggest some')
# TODO: Consider moving this to another command, since other
# git-cl owners commands deal with owners for a given CL.
parser.add_option(
'--show-all',
action='store_true',
help='Show all owners for a particular file')
auth.add_auth_options(parser)
options, args = parser.parse_args(args)
auth_config = auth.extract_auth_config_from_options(options)
......@@ -5375,6 +5381,17 @@ def CMDowners(parser, args):
cl = Changelist(auth_config=auth_config)
if options.show_all:
for arg in args:
base_branch = cl.GetCommonAncestorWithUpstream()
change = cl.GetChange(base_branch, None)
database = owners.Database(change.RepositoryRoot(), file, os.path)
database.load_data_needed_for([arg])
print('Owners for %s:' % arg)
for owner in sorted(database.all_possible_owners([arg], None)):
print(' - %s' % owner)
return 0
if args:
if len(args) > 1:
parser.error('Unknown args')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment