diff options
author | Oliver Poignant <oliver@poignant.se> | 2016-05-29 10:39:38 +0200 |
---|---|---|
committer | Oliver Poignant <oliver@poignant.se> | 2016-05-29 10:39:38 +0200 |
commit | 84e99d89e75b4c2e5e5e8678a15adb9d391daa44 (patch) | |
tree | 2258bb6d704d19e0a8bd7a043781bfa4f4ae214e /gitautodeploy | |
parent | 34b3205c0ce3c6bf54c42cd5296ee9a06befc452 (diff) | |
download | Git-Auto-Deploy-84e99d89e75b4c2e5e5e8678a15adb9d391daa44.zip Git-Auto-Deploy-84e99d89e75b4c2e5e5e8678a15adb9d391daa44.tar.gz Git-Auto-Deploy-84e99d89e75b4c2e5e5e8678a15adb9d391daa44.tar.bz2 |
Fixed issue when running on *nix. Refactoring
Diffstat (limited to 'gitautodeploy')
-rw-r--r-- | gitautodeploy/httpserver.py | 7 | ||||
-rw-r--r-- | gitautodeploy/wrappers/git.py | 32 |
2 files changed, 22 insertions, 17 deletions
diff --git a/gitautodeploy/httpserver.py b/gitautodeploy/httpserver.py index 96ba5cf..8032556 100644 --- a/gitautodeploy/httpserver.py +++ b/gitautodeploy/httpserver.py @@ -268,9 +268,10 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): res = GitWrapper.deploy(repo_config) repo_result['deploy'] = res - except Exception as e: - logger.error('Error during \'pull\' or \'deploy\' operation on path: %s' % repo_config['path']) - logger.error(e) + #except Exception as e: + # logger.error('Error during \'pull\' or \'deploy\' operation on path: %s' % repo_config['path']) + # logger.error(e) + # raise e finally: diff --git a/gitautodeploy/wrappers/git.py b/gitautodeploy/wrappers/git.py index 78a469c..3f29341 100644 --- a/gitautodeploy/wrappers/git.py +++ b/gitautodeploy/wrappers/git.py @@ -11,6 +11,7 @@ class GitWrapper(): import logging from process import ProcessWrapper import os + import platform logger = logging.getLogger() logger.info("Updating repository %s" % repo_config['path']) @@ -20,23 +21,26 @@ class GitWrapper(): logger.info('No local repository path configured, no pull will occure') return 0 - import platform + commands = [] if platform.system().lower() == "windows": # This assumes Git for Windows is installed. - cmd = ['"\Program Files\Git\usr\\bin\\bash.exe"', - ' -c "cd ' + repo_config['path'], - ' && unset GIT_DIR '] - else: - cmd = ['unset GIT_DIR '] - - cmd.append(' && git fetch ' + repo_config['remote']) - cmd.append(' && git reset --hard ' + repo_config['remote'] + '/' + repo_config['branch']) - cmd.append(' && git submodule init ') - cmd.append(' && git submodule update') - - # '&& git update-index --refresh ' +\ - res = ProcessWrapper().call([cmd], cwd=repo_config['path'], shell=True) + commands.append('"\Program Files\Git\usr\\bin\\bash.exe" -c "cd ' + repo_config['path']) + + commands.append('unset GIT_DIR') + commands.append('git fetch ' + repo_config['remote']) + commands.append('git reset --hard ' + repo_config['remote'] + '/' + repo_config['branch']) + commands.append('git submodule init') + commands.append('git submodule update') + #commands.append('git update-index --refresh') + + # All commands needs to success + for command in commands: + res = ProcessWrapper().call(command, cwd=repo_config['path'], shell=True) + + if res != 0: + logger.error("Command '%s' failed with exit code %s" % (command, res)) + break if res == 0 and os.path.isdir(repo_config['path']): logger.info("Repository %s successfully updated" % repo_config['path']) |