diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-03-11 11:56:49 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-03-11 13:05:28 +0000 |
commit | 076bf3106fcfe884d29be3ec16dcd8d7cef44fd0 (patch) | |
tree | 0db4a7fff8b2f2a922265500b0f18e4b522dd1ec | |
parent | 36cf89491a48e20002898a07b348e6f8c6064f54 (diff) | |
download | lorry-controller-076bf3106fcfe884d29be3ec16dcd8d7cef44fd0.tar.gz |
Allow glob patterns in the 'ignore' field for upstream Trovessam/ignore-globs
The documentation on wiki.baserock.org described the 'ignore' field as
"glob patterns on repository pathnames which to not mirror (trove only)"
but it was actually being treated as a simple list of repos to ignore.
Globs are much more useful.
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | lorrycontroller/lstroves.py | 14 |
2 files changed, 12 insertions, 7 deletions
@@ -126,8 +126,9 @@ Additionally, the following optional keys are allowed in Trove specifications: * `ignore` -- a list of git repositories from the other Trove that - should NOT be mirrored. Each list element is a path to the git - repository (not including leading slash). + should NOT be mirrored. Each list element is a glob pattern which + is matched against the path to the git repository (not including leading + slash). * `auth` -- specify how to authenticate to the remote Trove over https (only). It should be a dictionary with the fields `username` and diff --git a/lorrycontroller/lstroves.py b/lorrycontroller/lstroves.py index e69dce2..72515f5 100644 --- a/lorrycontroller/lstroves.py +++ b/lorrycontroller/lstroves.py @@ -1,4 +1,4 @@ -# Copyright (C) 2014 Codethink Limited +# Copyright (C) 2014-2015 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,12 +14,11 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import fnmatch import json import logging -import time import bottle -import cliapp import lorrycontroller @@ -83,8 +82,13 @@ class TroveRepositoryLister(object): return repo_paths def skip_ignored_repos(self, trovehost, repo_paths): - ignored_paths = json.loads(trovehost['ignore']) - return [x for x in repo_paths if x not in ignored_paths] + ignored_patterns = json.loads(trovehost['ignore']) + + ignored_paths = set() + for pattern in ignored_patterns: + ignored_paths.update(fnmatch.filter(repo_paths, pattern)) + + return set(repo_paths).difference(ignored_paths) def map_remote_repos_to_local_ones(self, trove_info, remote_paths): '''Return a dict that maps each remote repo path to a local one.''' |