Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. |
| 2 | # |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0+ |
Doug Anderson | 21a19d7 | 2012-12-03 14:43:16 +0000 | [diff] [blame] | 4 | # |
| 5 | |
| 6 | import command |
| 7 | import gitutil |
| 8 | import os |
| 9 | |
| 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 | 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 | |
| 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 ] |