summaryrefslogtreecommitdiffstats
path: root/GitAutoDeploy.py
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2015-05-02 14:47:35 +0200
committerOliver Poignant <oliver@poignant.se>2015-05-02 14:47:35 +0200
commit4016844083225a3ce55503721143568051050f5b (patch)
tree41b6fa3973faabf09bce3d7b8cbe03e723eb60b4 /GitAutoDeploy.py
parent1d528cb237354103c26e8b12bce5af6c947b8595 (diff)
parent1e085259cd760156e0ca2bb43f29e6c00f493734 (diff)
downloadGit-Auto-Deploy-4016844083225a3ce55503721143568051050f5b.zip
Git-Auto-Deploy-4016844083225a3ce55503721143568051050f5b.tar.gz
Git-Auto-Deploy-4016844083225a3ce55503721143568051050f5b.tar.bz2
Merge pull request #22 from quizzz-and-chiv/branch-in-config
Configure branch name in config file
Diffstat (limited to 'GitAutoDeploy.py')
-rwxr-xr-xGitAutoDeploy.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py
index bae734d..1bc6ead 100755
--- a/GitAutoDeploy.py
+++ b/GitAutoDeploy.py
@@ -45,10 +45,10 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
def do_process(self, urls):
for url in urls:
- paths = self.getMatchingPaths(url)
- for path in paths:
- self.pull(path)
- self.deploy(path)
+ repos = self.getMatchingPaths(url)
+ for repo in repos:
+ self.pull(repo['path'], repo['branch'])
+ self.deploy(repo['path'])
def parseRequest(self):
contenttype = self.headers.getheader('content-type')
@@ -100,7 +100,10 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
config = self.getConfig()
for repository in config['repositories']:
if(repository['url'] == repoUrl):
- res.append(repository['path'])
+ res.append({
+ 'path': repository['path'],
+ 'branch': ('branch' in repository) and repository['branch'] or 'master'
+ })
return res
def respond(self):
@@ -108,11 +111,11 @@ class GitAutoDeploy(BaseHTTPRequestHandler):
self.send_header('Content-type', 'text/plain')
self.end_headers()
- def pull(self, path):
+ def pull(self, path, branch):
if(not self.quiet):
print "\nPost push request received"
print 'Updating ' + path
- call(['cd "' + path + '" && git fetch origin ; git update-index --refresh &> /dev/null ; git reset --hard origin/master'], shell=True)
+ call(['cd "' + path + '" && git fetch origin ; git update-index --refresh &> /dev/null ; git reset --hard origin/' + branch], shell=True)
def deploy(self, path):
config = self.getConfig()