Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 2 | # Copyright (c) 2012 The Chromium OS Authors. |
| 3 | # |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 4 | |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 5 | import os |
| 6 | |
Simon Glass | bf77667 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 7 | from patman import command |
Simon Glass | bf77667 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 8 | |
Simon Glass | 967af26 | 2022-01-29 14:14:10 -0700 | [diff] [blame] | 9 | def find_get_maintainer(try_list): |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 10 | """Look for the get_maintainer.pl script. |
| 11 | |
Simon Glass | 156e655 | 2020-06-07 06:45:48 -0600 | [diff] [blame] | 12 | Args: |
| 13 | try_list: List of directories to try for the get_maintainer.pl script |
| 14 | |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 15 | Returns: |
| 16 | If the script is found we'll return a path to it; else None. |
| 17 | """ |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 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 | |
Simon Glass | 967af26 | 2022-01-29 14:14:10 -0700 | [diff] [blame] | 26 | def get_maintainer(dir_list, fname, verbose=False): |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 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: |
Simon Glass | 156e655 | 2020-06-07 06:45:48 -0600 | [diff] [blame] | 34 | dir_list: List of directories to try for the get_maintainer.pl script |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 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 | """ |
Simon Glass | 967af26 | 2022-01-29 14:14:10 -0700 | [diff] [blame] | 40 | get_maintainer = find_get_maintainer(dir_list) |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 41 | if not get_maintainer: |
| 42 | if verbose: |
Paul Burton | a920a17 | 2016-09-27 16:03:50 +0100 | [diff] [blame] | 43 | print("WARNING: Couldn't find get_maintainer.pl") |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 44 | return [] |
| 45 | |
Simon Glass | d980069 | 2022-01-29 14:14:05 -0700 | [diff] [blame] | 46 | stdout = command.output(get_maintainer, '--norolestats', fname) |
Stefan BrĂ¼ns | d1ccaa4 | 2017-12-31 23:21:17 +0100 | [diff] [blame] | 47 | lines = stdout.splitlines() |
| 48 | return [ x.replace('"', '') for x in lines ] |