diff options
author | Oliver Poignant <oliver@poignant.se> | 2016-03-13 18:29:10 +0100 |
---|---|---|
committer | Oliver Poignant <oliver@poignant.se> | 2016-03-13 18:29:10 +0100 |
commit | 00f822a13203b765d19b67fa998233d6b3ab223d (patch) | |
tree | 5a22b9b83a285302f866cb988a8e5859a5a15927 /gitautodeploy/httpserver.py | |
parent | 9a97f61d4a47a5dc9786f8ff7b5d4834f9afe7f5 (diff) | |
parent | 5a8caf8b9c9f4f283dffac33b461b5c43ad64eed (diff) | |
download | Git-Auto-Deploy-00f822a13203b765d19b67fa998233d6b3ab223d.zip Git-Auto-Deploy-00f822a13203b765d19b67fa998233d6b3ab223d.tar.gz Git-Auto-Deploy-00f822a13203b765d19b67fa998233d6b3ab223d.tar.bz2 |
Merge with stuff from master
Diffstat (limited to 'gitautodeploy/httpserver.py')
-rw-r--r-- | gitautodeploy/httpserver.py | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/gitautodeploy/httpserver.py b/gitautodeploy/httpserver.py index 1e0c198..0760067 100644 --- a/gitautodeploy/httpserver.py +++ b/gitautodeploy/httpserver.py @@ -53,7 +53,7 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): # Wait one second before we do git pull (why?) Timer(1.0, self.process_repositories, (repo_configs, ref, - action)).start() + action, request_body)).start() def log_message(self, format, *args): """Overloads the default message logging method to allow messages to @@ -112,7 +112,7 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): return - def process_repositories(self, repo_configs, ref, action): + def process_repositories(self, repo_configs, ref, action, request_body): import os import time import logging @@ -120,49 +120,33 @@ class WebhookRequestHandler(BaseHTTPRequestHandler): from lock import Lock logger = logging.getLogger() + data = json.loads(request_body) # Process each matching repository for repo_config in repo_configs: try: - # Verify that all filters matches the request if specified + # Verify that all filters matches the request (if any filters are specified) if 'filters' in repo_config: - for filter in repo_config['filters']: - - # Filter with both action and ref? - if 'action' in filter and 'ref' in filter: - - if filter['action'] == action and filter['ref'] == ref: - # This filter is a match, OK to proceed - continue - - raise FilterMatchError() - - # Filter with only action? - if 'action' in filter: - if filter['action'] == action: - # This filter is a match, OK to proceed - continue - - raise FilterMatchError() + # at least one filter must match + for filter in repo_config['filters']: - # Filter with only ref? - if 'ref' in filter: + # all options specified in the filter must match + for filter_key, filter_value in filter.iteritems(): - if filter['ref'] == ref: - # This filter is a match, OK to proceed + # support for earlier version so it's non-breaking functionality + if filter_key == 'action' and filter_value == action: continue - raise FilterMatchError() - - # Filter does not match, do not process this repo config - raise FilterMatchError() + if filter_key not in data or filter_value != data[filter_key]: + raise FilterMatchError() except FilterMatchError as e: + + # Filter does not match, do not process this repo config continue - # In case there is no path configured for the repository, no pull will # be made. if not 'path' in repo_config: |