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):
"""clone repo to destination"""
print("clone repo")
clone = ["git", "clone", self.task_detail["clone"]]
pull = ["git", "pull", self.task_detail["clone"]]
os.chdir("clone")
try:
subprocess.run(clone, check=True)
except subprocess.CalledProcessError:
print("git pull instead")
os.chdir(self.task)
subprocess.run(pull, check=True)
os.chdir("../")
os.chdir("../")
repo_dir = os.path.join(self.CLONE_BASE, self.task_detail["name"])
if os.path.exists(repo_dir):
command = ["git", "-C", repo_dir, "pull"]
else:
command = ["git", "clone", self.task_detail["clone"], repo_dir]
subprocess.run(command, check=True)
def build(self):
"""build the container"""