summaryrefslogtreecommitdiffstats
path: root/gitautodeploy/parsers/base.py
diff options
context:
space:
mode:
authorOliver Poignant <oliver@poignant.se>2017-01-08 17:15:58 +0100
committerOliver Poignant <oliver@poignant.se>2017-01-08 17:15:58 +0100
commit465cb9263fb1ffc9ba2d4a912847322920180caa (patch)
tree59932075b5f6426088704abac7c53f8c476da2a4 /gitautodeploy/parsers/base.py
parent324c3518d4b98da5bb660c62fa1503c47139c088 (diff)
downloadGit-Auto-Deploy-master.zip
Git-Auto-Deploy-master.tar.gz
Git-Auto-Deploy-master.tar.bz2
Diffstat (limited to 'gitautodeploy/parsers/base.py')
-rw-r--r--gitautodeploy/parsers/base.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/gitautodeploy/parsers/base.py b/gitautodeploy/parsers/base.py
new file mode 100644
index 0000000..f641d4c
--- /dev/null
+++ b/gitautodeploy/parsers/base.py
@@ -0,0 +1,29 @@
+class WebhookRequestParserBase(object):
+ """Abstract parent class for git service parsers. Contains helper
+ methods."""
+
+ def __init__(self, config):
+ self._config = config
+
+ def get_matching_repo_configs(self, urls, action):
+ """Iterates over the various repo URLs provided as argument (git://,
+ ssh:// and https:// for the repo) and compare them to any repo URL
+ specified in the config"""
+
+ configs = []
+ for url in urls:
+ for repo_config in self._config['repositories']:
+ if repo_config in configs:
+ continue
+ if repo_config.get('match-url', repo_config.get('url')) == url:
+ configs.append(repo_config)
+ elif 'url_without_usernme' in repo_config and repo_config['url_without_usernme'] == url:
+ configs.append(repo_config)
+
+ if len(configs) == 0:
+ action.log_warning('The URLs references in the webhook did not match any repository entry in the config. For this webhook to work, make sure you have at least one repository configured with one of the following URLs; %s' % ', '.join(urls))
+
+ return configs
+
+ def validate_request(self, request_headers, repo_configs, action):
+ return True