From e783316049573ee47ceff1cdb2bb1428f2d5608f Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sat, 21 Dec 2019 14:53:42 +0100 Subject: [PATCH] Store git_repo_path as a property of MicroAnnotateGenerator, so we don't have to pass it around --- scripts/microannotate_generator.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/microannotate_generator.py b/scripts/microannotate_generator.py index 23cbcfd8..0e467a6f 100644 --- a/scripts/microannotate_generator.py +++ b/scripts/microannotate_generator.py @@ -22,6 +22,7 @@ class MicroannotateGenerator(object): def __init__(self, cache_root, repo_url, tokenize, remove_comments): self.cache_root = cache_root self.repo_url = repo_url + self.git_repo_path = os.path.basename(self.repo_url) self.tokenize = tokenize self.remove_comments = remove_comments @@ -41,9 +42,8 @@ class MicroannotateGenerator(object): repo_push_url = self.repo_url.replace( "https://", f"https://{git_user}:{git_password}@" ) - git_repo_path = os.path.basename(self.repo_url) - executor.submit(self.clone_git_repo, git_repo_path) + executor.submit(self.clone_git_repo) retry( lambda: subprocess.run( @@ -55,8 +55,8 @@ class MicroannotateGenerator(object): while not done: done = generator.generate( self.repo_dir, - git_repo_path, - limit=COMMITS_STEP, + self.git_repo_path, + limit=1, tokenize=self.tokenize, remove_comments=self.remove_comments, ) @@ -64,15 +64,16 @@ class MicroannotateGenerator(object): retry( lambda: subprocess.run( ["git", "push", repo_push_url, "master"], - cwd=git_repo_path, + cwd=self.git_repo_path, check=True, ) ) - def clone_git_repo(self, git_repo_path): + def clone_git_repo(self): retry( lambda: subprocess.run( - ["git", "clone", "--quiet", self.repo_url, git_repo_path], check=True + ["git", "clone", "--quiet", self.repo_url, self.git_repo_path], + check=True, ) ) @@ -80,7 +81,7 @@ class MicroannotateGenerator(object): retry( lambda: subprocess.run( ["git", "pull", "--quiet", self.repo_url, "master"], - cwd=git_repo_path, + cwd=self.git_repo_path, capture_output=True, check=True, )