get_maintainer.py 1.9 KB

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