summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2016-08-26 22:56:05 +0200
committerOliver Poignant <oliver@poignant.se>2016-08-26 22:56:05 +0200
commit027d1fb8ddbfb046b4dada8bd2504db4b9a83c6e (patch)
tree5f6abcaad3a34aa9bace3d1f1abe175202a4091c
parentd23233780c4223404b9585b52d3bc993b5626b67 (diff)
downloadGit-Auto-Deploy-027d1fb8ddbfb046b4dada8bd2504db4b9a83c6e.zip
Git-Auto-Deploy-027d1fb8ddbfb046b4dada8bd2504db4b9a83c6e.tar.gz
Git-Auto-Deploy-027d1fb8ddbfb046b4dada8bd2504db4b9a83c6e.tar.bz2
Breaks when using logger in config module
Revert "Move config checks into cli/config module" This reverts commit 7720ec0cf45bb0b44e3e5b56116545237918d448.
-rw-r--r--gitautodeploy/cli/config.py14
-rw-r--r--gitautodeploy/gitautodeploy.py17
-rw-r--r--gitautodeploy/wrappers/git.py10
3 files changed, 25 insertions, 16 deletions
diff --git a/gitautodeploy/cli/config.py b/gitautodeploy/cli/config.py
index 302bcae..b23135f 100644
--- a/gitautodeploy/cli/config.py
+++ b/gitautodeploy/cli/config.py
@@ -246,16 +246,6 @@ 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"
@@ -311,7 +301,7 @@ def init_config(config):
filter['pull_request'] = True
- return 0
+ return config
def get_repo_config_from_environment():
"""Look for repository config in any defined environment variables. If
@@ -342,4 +332,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
+ return repo_config \ No newline at end of file
diff --git a/gitautodeploy/gitautodeploy.py b/gitautodeploy/gitautodeploy.py
index 5d67851..8347d6a 100644
--- a/gitautodeploy/gitautodeploy.py
+++ b/gitautodeploy/gitautodeploy.py
@@ -97,6 +97,18 @@ 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'):
GitWrapper.init(repo_config)
else:
@@ -455,10 +467,7 @@ def main():
config['repositories'].append(repo_config)
# Initialize config by expanding with missing values
- if init_config(config) != 0:
- app.close()
- app.exit()
- return
+ init_config(config)
app.setup(config)
app.serve_forever()
diff --git a/gitautodeploy/wrappers/git.py b/gitautodeploy/wrappers/git.py
index 9bca474..910e9f6 100644
--- a/gitautodeploy/wrappers/git.py
+++ b/gitautodeploy/wrappers/git.py
@@ -56,6 +56,11 @@ 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
@@ -95,6 +100,11 @@ 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'])