]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | # SPDX-License-Identifier: GPL-2.0+ |
21a19d70 DA |
2 | # Copyright (c) 2012 The Chromium OS Authors. |
3 | # | |
21a19d70 DA |
4 | |
5 | import command | |
6 | import gitutil | |
7 | import os | |
8 | ||
9 | def FindGetMaintainer(): | |
10 | """Look for the get_maintainer.pl script. | |
11 | ||
12 | Returns: | |
13 | If the script is found we'll return a path to it; else None. | |
14 | """ | |
15 | try_list = [ | |
16 | os.path.join(gitutil.GetTopLevel(), 'scripts'), | |
17 | ] | |
18 | # Look in the list | |
19 | for path in try_list: | |
20 | fname = os.path.join(path, 'get_maintainer.pl') | |
21 | if os.path.isfile(fname): | |
22 | return fname | |
23 | ||
24 | return None | |
25 | ||
26 | def GetMaintainer(fname, verbose=False): | |
27 | """Run get_maintainer.pl on a file if we find it. | |
28 | ||
29 | We look for get_maintainer.pl in the 'scripts' directory at the top of | |
30 | git. If we find it we'll run it. If we don't find get_maintainer.pl | |
31 | then we fail silently. | |
32 | ||
33 | Args: | |
34 | fname: Path to the patch file to run get_maintainer.pl on. | |
35 | ||
36 | Returns: | |
37 | A list of email addresses to CC to. | |
38 | """ | |
39 | get_maintainer = FindGetMaintainer() | |
40 | if not get_maintainer: | |
41 | if verbose: | |
a920a17b | 42 | print("WARNING: Couldn't find get_maintainer.pl") |
21a19d70 DA |
43 | return [] |
44 | ||
45 | stdout = command.Output(get_maintainer, '--norolestats', fname) | |
d1ccaa47 SB |
46 | lines = stdout.splitlines() |
47 | return [ x.replace('"', '') for x in lines ] |