diff options
author | Torben <torben.letorbi@gmail.com> | 2016-07-08 15:52:42 +0200 |
---|---|---|
committer | Torben <torben.letorbi@gmail.com> | 2016-07-08 15:52:42 +0200 |
commit | 7720ec0cf45bb0b44e3e5b56116545237918d448 (patch) | |
tree | e94a9f2b7f0b8a0920e0192ab4e5b48ca4cbb266 /gitautodeploy | |
parent | 2e25cb624a41143bebaea6ec59cce2a2b3b3c3a3 (diff) | |
download | Git-Auto-Deploy-7720ec0cf45bb0b44e3e5b56116545237918d448.zip Git-Auto-Deploy-7720ec0cf45bb0b44e3e5b56116545237918d448.tar.gz Git-Auto-Deploy-7720ec0cf45bb0b44e3e5b56116545237918d448.tar.bz2 |
Move config checks into cli/config module
Diffstat (limited to 'gitautodeploy')
-rw-r--r-- | gitautodeploy/cli/config.py | 14 | ||||
-rw-r--r-- | gitautodeploy/gitautodeploy.py | 17 | ||||
-rw-r--r-- | gitautodeploy/wrappers/git.py | 10 |
3 files changed, 16 insertions, 25 deletions
diff --git a/gitautodeploy/cli/config.py b/gitautodeploy/cli/config.py index b23135f..302bcae 100644 --- a/gitautodeploy/cli/config.py +++ b/gitautodeploy/cli/config.py @@ -246,6 +246,16 @@ def init_config(config): for repo_config in config['repositories']: + # Only clone repositories with a configured path + if 'url' not in repo_config: + logger.critical("Repository has no configured URL") + return 1 + + # Only clone repositories with a configured path + if 'path' not in repo_config: + logger.critical("Repository has no configured path") + return 2 + # Setup branch if missing if 'branch' not in repo_config: repo_config['branch'] = "master" @@ -301,7 +311,7 @@ def init_config(config): filter['pull_request'] = True - return config + return 0 def get_repo_config_from_environment(): """Look for repository config in any defined environment variables. If @@ -332,4 +342,4 @@ def get_repo_config_from_environment(): if 'GAD_REPO_DEPLOY' in os.environ: repo_config['deploy'] = os.environ['GAD_REPO_DEPLOY'] - return repo_config
\ No newline at end of file + return repo_config diff --git a/gitautodeploy/gitautodeploy.py b/gitautodeploy/gitautodeploy.py index 095401a..2a3b27e 100644 --- a/gitautodeploy/gitautodeploy.py +++ b/gitautodeploy/gitautodeploy.py @@ -97,18 +97,6 @@ class GitAutoDeploy(object): # Iterate over all configured repositories for repo_config in self._config['repositories']: - # Only clone repositories with a configured path - if 'url' not in repo_config: - logger.critical("Repository has no configured URL") - self.close() - self.exit() - return - - # Only clone repositories with a configured path - if 'path' not in repo_config: - logger.debug("Repository %s will not be cloned (no path configured)" % repo_config['url']) - continue - if os.path.isdir(repo_config['path']) and os.path.isdir(repo_config['path']+'/.git'): # Pull repository logger.debug("Repository %s already present and will be updated" % repo_config['url']) @@ -460,7 +448,10 @@ def main(): config['repositories'].append(repo_config) # Initialize config by expanding with missing values - init_config(config) + if init_config(config) != 0: + app.close() + app.exit() + return app.setup(config) app.serve_forever() diff --git a/gitautodeploy/wrappers/git.py b/gitautodeploy/wrappers/git.py index 19820ed..4ccd863 100644 --- a/gitautodeploy/wrappers/git.py +++ b/gitautodeploy/wrappers/git.py @@ -16,11 +16,6 @@ class GitWrapper(): logger = logging.getLogger() logger.info("Updating repository %s" % repo_config['path']) - # Only pull if there is actually a local copy of the repository - if 'path' not in repo_config: - logger.info('No local repository path configured, no pull will occure') - return 0 - commands = [] # On Windows, bash command needs to be run using bash.exe. This assumes bash.exe @@ -59,11 +54,6 @@ class GitWrapper(): logger = logging.getLogger() logger.info("Cloning repository %s" % repo_config['path']) - # Only pull if there is actually a local copy of the repository - if 'path' not in repo_config: - logger.info('No local repository path configured, no clone will occure') - return 0 - commands = [] commands.append('unset GIT_DIR') commands.append('git clone --recursive ' + repo_config['url'] + ' -b ' + repo_config['branch'] + ' ' + repo_config['path']) |