2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2012-12-03 14:43:16 +00:00
|
|
|
# Copyright (c) 2012 The Chromium OS Authors.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2020-04-18 00:09:04 +00:00
|
|
|
from patman import command
|
|
|
|
|
2022-01-29 21:14:10 +00:00
|
|
|
def find_get_maintainer(try_list):
|
2012-12-03 14:43:16 +00:00
|
|
|
"""Look for the get_maintainer.pl script.
|
|
|
|
|
2020-06-07 12:45:48 +00:00
|
|
|
Args:
|
|
|
|
try_list: List of directories to try for the get_maintainer.pl script
|
|
|
|
|
2012-12-03 14:43:16 +00:00
|
|
|
Returns:
|
|
|
|
If the script is found we'll return a path to it; else None.
|
|
|
|
"""
|
|
|
|
# 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
|
|
|
|
|
2022-01-29 21:14:10 +00:00
|
|
|
def get_maintainer(dir_list, fname, verbose=False):
|
2012-12-03 14:43:16 +00:00
|
|
|
"""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:
|
2020-06-07 12:45:48 +00:00
|
|
|
dir_list: List of directories to try for the get_maintainer.pl script
|
2012-12-03 14:43:16 +00:00
|
|
|
fname: Path to the patch file to run get_maintainer.pl on.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A list of email addresses to CC to.
|
|
|
|
"""
|
2022-01-29 21:14:10 +00:00
|
|
|
get_maintainer = find_get_maintainer(dir_list)
|
2012-12-03 14:43:16 +00:00
|
|
|
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 []
|
|
|
|
|
2022-01-29 21:14:05 +00:00
|
|
|
stdout = command.output(get_maintainer, '--norolestats', fname)
|
2017-12-31 22:21:17 +00:00
|
|
|
lines = stdout.splitlines()
|
|
|
|
return [ x.replace('"', '') for x in lines ]
|