From cbb56f4405405deabdde03b09e3a6f7bb3fd4975 Mon Sep 17 00:00:00 2001 From: Ingmar Steen Date: Tue, 14 May 2013 11:31:19 +0200 Subject: [PATCH 1/3] Allow filtering by ref --- GitAutoDeploy.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index d642e95..199d034 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -33,9 +33,9 @@ def getConfig(myClass): return myClass.config def do_POST(self): - urls = self.parseRequest() - for url in urls: - paths = self.getMatchingPaths(url) + url_refs = self.parseRequest() + for url, ref in url_refs: + paths = self.getMatchingPaths(url, ref) for path in paths: self.pull(path) self.deploy(path) @@ -47,14 +47,14 @@ def parseRequest(self): items = [] for itemString in post['payload']: item = json.loads(itemString) - items.append(item['repository']['url']) + items.append((item['repository']['url'], item['ref'])) return items - def getMatchingPaths(self, repoUrl): + def getMatchingPaths(self, repoUrl, ref): res = [] config = self.getConfig() for repository in config['repositories']: - if(repository['url'] == repoUrl): + if(repository['url'] == repoUrl and repository.get('ref', '') in ('', ref)): res.append(repository['path']) return res From b14e4dd8675db87e744517f36275202facbb3ae3 Mon Sep 17 00:00:00 2001 From: Eduard Schleining Date: Tue, 4 Mar 2014 18:30:20 +0100 Subject: [PATCH 2/3] Added self.respond() to do_POST(self) method --- GitAutoDeploy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index d642e95..23a429b 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -39,6 +39,7 @@ def do_POST(self): for path in paths: self.pull(path) self.deploy(path) + self.respond() def parseRequest(self): length = int(self.headers.getheader('content-length')) From e2ce82ccaf93fd080fe653fc98b5e46794a62f38 Mon Sep 17 00:00:00 2001 From: Eduard Schleining Date: Mon, 10 Mar 2014 13:01:03 +0100 Subject: [PATCH 3/3] Added response to Server --- GitAutoDeploy.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 7f57628..3222571 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -34,12 +34,15 @@ def getConfig(myClass): def do_POST(self): url_refs = self.parseRequest() + matchingPaths = [] for url, ref in url_refs: paths = self.getMatchingPaths(url, ref) - for path in paths: - self.pull(path) - self.deploy(path) - self.respond() + for path in paths: + matchingPaths.append(path) + self.respond(matchingPaths) + for path in matchingPaths: + self.pull(path) + self.deploy(path) def parseRequest(self): length = int(self.headers.getheader('content-length')) @@ -59,10 +62,16 @@ def getMatchingPaths(self, repoUrl, ref): res.append(repository['path']) return res - def respond(self): - self.send_response(200) + def respond(self,paths): + self.send_response(200,paths) self.send_header('Content-type', 'text/plain') self.end_headers() + if (len(paths) == 0): + self.wfile.write('No repositorys need to be redeployed.') + else: + for path in paths: + self.wfile.write('\"' + path + '\" Will be redeployed.') + def pull(self, path): if(not self.quiet):