diff options
author | Alexander Nestorov <alexandernst@gmail.com> | 2014-09-18 22:39:44 +0200 |
---|---|---|
committer | Alexander Nestorov <alexandernst@gmail.com> | 2014-09-18 22:39:44 +0200 |
commit | e34a2cb172a932fa525aabaa1887fca0b6dba96b (patch) | |
tree | 133e818e48e33cc2163a4302b571e3e812ca8c34 /GitAutoDeploy.py | |
parent | 4f6c7bd23c398e15cf56d121905d791c84234310 (diff) | |
download | Git-Auto-Deploy-e34a2cb172a932fa525aabaa1887fca0b6dba96b.zip Git-Auto-Deploy-e34a2cb172a932fa525aabaa1887fca0b6dba96b.tar.gz Git-Auto-Deploy-e34a2cb172a932fa525aabaa1887fca0b6dba96b.tar.bz2 |
Do a hard pull to avoid conflicts
Diffstat (limited to 'GitAutoDeploy.py')
-rwxr-xr-x | GitAutoDeploy.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 1d43b2f..3e21954 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -45,19 +45,19 @@ class GitAutoDeploy(BaseHTTPRequestHandler): body = self.rfile.read(length) post = urlparse.parse_qs(body) items = [] - + # If payload is missing, we assume gitlab syntax. if not 'payload' in post: response = json.loads(body) if 'repository' in body: items.append(response['repository']['url']) - + # Otherwise, we assume github syntax. else: for itemString in post['payload']: item = json.loads(itemString) items.append(item['repository']['url']) - + return items def getMatchingPaths(self, repoUrl): @@ -77,7 +77,7 @@ class GitAutoDeploy(BaseHTTPRequestHandler): if(not self.quiet): print "\nPost push request received" print 'Updating ' + path - call(['cd "' + path + '" && git pull'], shell=True) + call(['cd "' + path + '" && git fetch origin && git update-index --refresh &> /dev/null && git reset --hard origin/master'], shell=True) def deploy(self, path): config = self.getConfig() @@ -92,13 +92,13 @@ class GitAutoDeploy(BaseHTTPRequestHandler): def main(): try: server = None - for arg in sys.argv: + for arg in sys.argv: if(arg == '-d' or arg == '--daemon-mode'): GitAutoDeploy.daemon = True GitAutoDeploy.quiet = True if(arg == '-q' or arg == '--quiet'): GitAutoDeploy.quiet = True - + if(GitAutoDeploy.daemon): pid = os.fork() if(pid != 0): @@ -109,7 +109,7 @@ def main(): print 'Github & Gitlab Autodeploy Service v 0.1 started' else: print 'Github & Gitlab Autodeploy Service v 0.1 started in daemon mode' - + server = HTTPServer(('', GitAutoDeploy.getConfig()['port']), GitAutoDeploy) server.serve_forever() except (KeyboardInterrupt, SystemExit) as e: |