summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-03-11 16:01:46 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-03-11 16:01:46 +0000
commitf3f59d1415bfdb18f17bd910b829a8d128c1562a (patch)
tree0db4a7fff8b2f2a922265500b0f18e4b522dd1ec
parentf605163c58bff85c49118f4026f9e4a194189104 (diff)
parent076bf3106fcfe884d29be3ec16dcd8d7cef44fd0 (diff)
downloadlorry-controller-f3f59d1415bfdb18f17bd910b829a8d128c1562a.tar.gz
Merge branch 'sam/ignore-globs'
Reviewed-By: Pedro Alvarez <pedro.alvarez@codethink.co.uk> Reviewed-By: Adam Coldrick <adam.coldrick@codethink.co.uk>
-rw-r--r--README5
-rw-r--r--lorrycontroller/lstroves.py14
2 files changed, 12 insertions, 7 deletions
diff --git a/README b/README
index 31ad55e..d5e9d8a 100644
--- a/README
+++ b/README
@@ -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.'''