1*21a19d70SDoug Anderson# Copyright (c) 2012 The Chromium OS Authors. 2*21a19d70SDoug Anderson# 3*21a19d70SDoug Anderson# See file CREDITS for list of people who contributed to this 4*21a19d70SDoug Anderson# project. 5*21a19d70SDoug Anderson# 6*21a19d70SDoug Anderson# This program is free software; you can redistribute it and/or 7*21a19d70SDoug Anderson# modify it under the terms of the GNU General Public License as 8*21a19d70SDoug Anderson# published by the Free Software Foundation; either version 2 of 9*21a19d70SDoug Anderson# the License, or (at your option) any later version. 10*21a19d70SDoug Anderson# 11*21a19d70SDoug Anderson# This program is distributed in the hope that it will be useful, 12*21a19d70SDoug Anderson# but WITHOUT ANY WARRANTY; without even the implied warranty of 13*21a19d70SDoug Anderson# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*21a19d70SDoug Anderson# GNU General Public License for more details. 15*21a19d70SDoug Anderson# 16*21a19d70SDoug Anderson# You should have received a copy of the GNU General Public License 17*21a19d70SDoug Anderson# along with this program; if not, write to the Free Software 18*21a19d70SDoug Anderson# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19*21a19d70SDoug Anderson# MA 02111-1307 USA 20*21a19d70SDoug Anderson# 21*21a19d70SDoug Anderson 22*21a19d70SDoug Andersonimport command 23*21a19d70SDoug Andersonimport gitutil 24*21a19d70SDoug Andersonimport os 25*21a19d70SDoug Anderson 26*21a19d70SDoug Andersondef FindGetMaintainer(): 27*21a19d70SDoug Anderson """Look for the get_maintainer.pl script. 28*21a19d70SDoug Anderson 29*21a19d70SDoug Anderson Returns: 30*21a19d70SDoug Anderson If the script is found we'll return a path to it; else None. 31*21a19d70SDoug Anderson """ 32*21a19d70SDoug Anderson try_list = [ 33*21a19d70SDoug Anderson os.path.join(gitutil.GetTopLevel(), 'scripts'), 34*21a19d70SDoug Anderson ] 35*21a19d70SDoug Anderson # Look in the list 36*21a19d70SDoug Anderson for path in try_list: 37*21a19d70SDoug Anderson fname = os.path.join(path, 'get_maintainer.pl') 38*21a19d70SDoug Anderson if os.path.isfile(fname): 39*21a19d70SDoug Anderson return fname 40*21a19d70SDoug Anderson 41*21a19d70SDoug Anderson return None 42*21a19d70SDoug Anderson 43*21a19d70SDoug Andersondef GetMaintainer(fname, verbose=False): 44*21a19d70SDoug Anderson """Run get_maintainer.pl on a file if we find it. 45*21a19d70SDoug Anderson 46*21a19d70SDoug Anderson We look for get_maintainer.pl in the 'scripts' directory at the top of 47*21a19d70SDoug Anderson git. If we find it we'll run it. If we don't find get_maintainer.pl 48*21a19d70SDoug Anderson then we fail silently. 49*21a19d70SDoug Anderson 50*21a19d70SDoug Anderson Args: 51*21a19d70SDoug Anderson fname: Path to the patch file to run get_maintainer.pl on. 52*21a19d70SDoug Anderson 53*21a19d70SDoug Anderson Returns: 54*21a19d70SDoug Anderson A list of email addresses to CC to. 55*21a19d70SDoug Anderson """ 56*21a19d70SDoug Anderson get_maintainer = FindGetMaintainer() 57*21a19d70SDoug Anderson if not get_maintainer: 58*21a19d70SDoug Anderson if verbose: 59*21a19d70SDoug Anderson print "WARNING: Couldn't find get_maintainer.pl" 60*21a19d70SDoug Anderson return [] 61*21a19d70SDoug Anderson 62*21a19d70SDoug Anderson stdout = command.Output(get_maintainer, '--norolestats', fname) 63*21a19d70SDoug Anderson return stdout.splitlines() 64