Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Doug Anderson | c2c84bc | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 2 | # Copyright (c) 2012 The Chromium OS Authors. |
| 3 | # |
Doug Anderson | c2c84bc | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 4 | |
Doug Anderson | c2c84bc | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 5 | import os |
| 6 | |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 7 | from patman import command |
| 8 | from patman import gitutil |
| 9 | |
Doug Anderson | c2c84bc | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 10 | def FindGetMaintainer(): |
| 11 | """Look for the get_maintainer.pl script. |
| 12 | |
| 13 | Returns: |
| 14 | If the script is found we'll return a path to it; else None. |
| 15 | """ |
| 16 | try_list = [ |
| 17 | os.path.join(gitutil.GetTopLevel(), 'scripts'), |
| 18 | ] |
| 19 | # Look in the list |
| 20 | for path in try_list: |
| 21 | fname = os.path.join(path, 'get_maintainer.pl') |
| 22 | if os.path.isfile(fname): |
| 23 | return fname |
| 24 | |
| 25 | return None |
| 26 | |
| 27 | def GetMaintainer(fname, verbose=False): |
| 28 | """Run get_maintainer.pl on a file if we find it. |
| 29 | |
| 30 | We look for get_maintainer.pl in the 'scripts' directory at the top of |
| 31 | git. If we find it we'll run it. If we don't find get_maintainer.pl |
| 32 | then we fail silently. |
| 33 | |
| 34 | Args: |
| 35 | fname: Path to the patch file to run get_maintainer.pl on. |
| 36 | |
| 37 | Returns: |
| 38 | A list of email addresses to CC to. |
| 39 | """ |
| 40 | get_maintainer = FindGetMaintainer() |
| 41 | if not get_maintainer: |
| 42 | if verbose: |
Paul Burton | c393134 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 43 | print("WARNING: Couldn't find get_maintainer.pl") |
Doug Anderson | c2c84bc | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 44 | return [] |
| 45 | |
| 46 | stdout = command.Output(get_maintainer, '--norolestats', fname) |
Stefan BrĂ¼ns | 5d3a5fa | 2017-12-31 23:21:17 +0100 | [diff] [blame] | 47 | lines = stdout.splitlines() |
| 48 | return [ x.replace('"', '') for x in lines ] |