From patchwork Fri May 22 02:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 246218 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Thu, 21 May 2020 20:29:03 -0600 Subject: [PATCH v3 4/5] patman: Pass in maintainer dirs to avoid and import In-Reply-To: <20200522022904.239301-1-sjg@chromium.org> References: <20200522022904.239301-1-sjg@chromium.org> Message-ID: <20200522022904.239301-4-sjg@chromium.org> Adjust the get_maintainer module to accept a list of directories to search for the script. This avoids needing to import gitutil. Signed-off-by: Simon Glass Reported-by: Stefan Bosch --- Changes in v3: None Changes in v2: None tools/patman/get_maintainer.py | 14 +++++++------- tools/patman/series.py | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py index 473f0feebf4..af4ba15bcdd 100644 --- a/tools/patman/get_maintainer.py +++ b/tools/patman/get_maintainer.py @@ -5,17 +5,16 @@ import os from patman import command -from patman import gitutil -def FindGetMaintainer(): +def FindGetMaintainer(try_list): """Look for the get_maintainer.pl script. + Args: + try_list: List of directories to try for the get_maintainer.pl script + Returns: If the script is found we'll return a path to it; else None. """ - try_list = [ - os.path.join(gitutil.GetTopLevel(), 'scripts'), - ] # Look in the list for path in try_list: fname = os.path.join(path, 'get_maintainer.pl') @@ -24,7 +23,7 @@ def FindGetMaintainer(): return None -def GetMaintainer(fname, verbose=False): +def GetMaintainer(dir_list, fname, verbose=False): """Run get_maintainer.pl on a file if we find it. We look for get_maintainer.pl in the 'scripts' directory at the top of @@ -32,12 +31,13 @@ def GetMaintainer(fname, verbose=False): then we fail silently. Args: + dir_list: List of directories to try for the get_maintainer.pl script fname: Path to the patch file to run get_maintainer.pl on. Returns: A list of email addresses to CC to. """ - get_maintainer = FindGetMaintainer() + get_maintainer = FindGetMaintainer(dir_list) if not get_maintainer: if verbose: print("WARNING: Couldn't find get_maintainer.pl") diff --git a/tools/patman/series.py b/tools/patman/series.py index e5e28cebdf5..e6c72a9317b 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -233,7 +233,8 @@ class Series(dict): if type(add_maintainers) == type(cc): cc += add_maintainers elif add_maintainers: - cc += get_maintainer.GetMaintainer(commit.patch) + dir_list = [os.path.join(gitutil.GetTopLevel(), 'scripts')] + cc += get_maintainer.GetMaintainer(dir_list, commit.patch) for x in set(cc) & set(settings.bounces): print(col.Color(col.YELLOW, 'Skipping "%s"' % x)) cc = set(cc) - set(settings.bounces)