summaryrefslogtreecommitdiffstats
path: root/gitautodeploy/wrappers/git.py
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2016-05-29 10:39:38 +0200
committerOliver Poignant <oliver@poignant.se>2016-05-29 10:39:38 +0200
commit84e99d89e75b4c2e5e5e8678a15adb9d391daa44 (patch)
tree2258bb6d704d19e0a8bd7a043781bfa4f4ae214e /gitautodeploy/wrappers/git.py
parent34b3205c0ce3c6bf54c42cd5296ee9a06befc452 (diff)
downloadGit-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/wrappers/git.py')
-rw-r--r--gitautodeploy/wrappers/git.py32
1 files changed, 18 insertions, 14 deletions
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'])