2012-12-03 14:43:16 +00:00
|
|
|
# Copyright (c) 2012 The Chromium OS Authors.
|
|
|
|
#
|
2013-07-08 07:37:19 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2012-12-03 14:43:16 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
import command
|
|
|
|
import gitutil
|
|
|
|
import os
|
|
|
|
|
|
|
|
def FindGetMaintainer():
|
|
|
|
"""Look for the get_maintainer.pl script.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
If the script is found we'll return a path to it; else None.
|
|
|
|
"""
|
|
|
|
try_list = [
|
|
|
|
os.path.join(gitutil.GetTopLevel(), 'scripts'),
|
|
|
|
]
|
|
|
|
# Look in the list
|
|
|
|
for path in try_list:
|
|
|
|
fname = os.path.join(path, 'get_maintainer.pl')
|
|
|
|
if os.path.isfile(fname):
|
|
|
|
return fname
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
def GetMaintainer(fname, verbose=False):
|
|
|
|
"""Run get_maintainer.pl on a file if we find it.
|
|
|
|
|
|
|
|
We look for get_maintainer.pl in the 'scripts' directory at the top of
|
|
|
|
git. If we find it we'll run it. If we don't find get_maintainer.pl
|
|
|
|
then we fail silently.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
fname: Path to the patch file to run get_maintainer.pl on.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A list of email addresses to CC to.
|
|
|
|
"""
|
|
|
|
get_maintainer = FindGetMaintainer()
|
|
|
|
if not get_maintainer:
|
|
|
|
if verbose:
|
2016-09-27 15:03:50 +00:00
|
|
|
print("WARNING: Couldn't find get_maintainer.pl")
|
2012-12-03 14:43:16 +00:00
|
|
|
return []
|
|
|
|
|
|
|
|
stdout = command.Output(get_maintainer, '--norolestats', fname)
|
|
|
|
return stdout.splitlines()
|