From cbb56f4405405deabdde03b09e3a6f7bb3fd4975 Mon Sep 17 00:00:00 2001 From: Ingmar Steen Date: Tue, 14 May 2013 11:31:19 +0200 Subject: [PATCH] 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