better clone-pull path building

This commit is contained in:
simon 2022-06-02 07:55:53 +07:00
parent 4158bae090
commit e6ec703eac
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -96,17 +96,13 @@ class Builder(RedisBase):
def clone(self): def clone(self):
"""clone repo to destination""" """clone repo to destination"""
print("clone repo") print("clone repo")
clone = ["git", "clone", self.task_detail["clone"]] repo_dir = os.path.join(self.CLONE_BASE, self.task_detail["name"])
pull = ["git", "pull", self.task_detail["clone"]] if os.path.exists(repo_dir):
os.chdir("clone") command = ["git", "-C", repo_dir, "pull"]
try: else:
subprocess.run(clone, check=True) command = ["git", "clone", self.task_detail["clone"], repo_dir]
except subprocess.CalledProcessError:
print("git pull instead") subprocess.run(command, check=True)
os.chdir(self.task)
subprocess.run(pull, check=True)
os.chdir("../")
os.chdir("../")
def build(self): def build(self):
"""build the container""" """build the container"""