blob: 2deb5db6ecff7bcfc9c4ba3da5905eb6d7e36476 [file] [log] [blame]
Doug Anderson21a19d72012-12-03 14:43:16 +00001# Copyright (c) 2012 The Chromium OS Authors.
2#
Wolfgang Denk1a459662013-07-08 09:37:19 +02003# SPDX-License-Identifier: GPL-2.0+
Doug Anderson21a19d72012-12-03 14:43:16 +00004#
5
6import command
7import gitutil
8import os
9
10def 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
27def 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 Burtona920a172016-09-27 16:03:50 +010043 print("WARNING: Couldn't find get_maintainer.pl")
Doug Anderson21a19d72012-12-03 14:43:16 +000044 return []
45
46 stdout = command.Output(get_maintainer, '--norolestats', fname)
47 return stdout.splitlines()