From 62e13d7edb937cbd730ef2dd0bf15f23932d4f2c Mon Sep 17 00:00:00 2001 From: Peter Dahlberg Date: Mon, 13 Jun 2016 01:51:39 +0200 Subject: [PATCH] fix repo creation --- pelican_deploy/deploy.py | 8 ++++++-- pelican_deploy/gittool.py | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pelican_deploy/deploy.py b/pelican_deploy/deploy.py index ddecaed..d9ac8f2 100644 --- a/pelican_deploy/deploy.py +++ b/pelican_deploy/deploy.py @@ -57,6 +57,9 @@ class DeploymentRunner: self._update_build_repository() def _update_build_repository(self): + if not self.build_repo_path.exists(): + self.build_repo_path.mkdir(parents=True) + repo = Repo(str(self.build_repo_path)) if not repo.is_repo(): if self.build_repo_path.is_dir() and \ @@ -67,8 +70,9 @@ class DeploymentRunner: raise RuntimeException(("non-empty {} exists but not a" "valid git repository!").format(self.build_repo_path)) else: - log.info("Build repository %s not there, cloneing", e) - result = repo.clone("--branch", "self.git_branch", + log.info("Build repository %s not there, cloning", + self.build_repo_path) + result = repo.clone("--branch", self.git_branch, "--depth", "1", self.clone_url, ".") log_git(result) diff --git a/pelican_deploy/gittool.py b/pelican_deploy/gittool.py index b191f1c..5af5342 100644 --- a/pelican_deploy/gittool.py +++ b/pelican_deploy/gittool.py @@ -1,4 +1,5 @@ import os +import errno import shlex from collections import namedtuple from subprocess import Popen, PIPE @@ -13,6 +14,9 @@ class GitCommandError(Exception): class Repo: def __init__(self, repo_dir, git_cmd="git", default_timeout=None): + if not os.path.exists(repo_dir): + raise FileNotFoundError(errno.ENOENT, "Path, does not exist", + repo_dir) self.repo_dir = repo_dir self.git_cmd = git_cmd self.default_timeout = default_timeout