Skip to content

Commit 4c526a0

Browse files
committed
support pattern matching ignored project names
fixes #4084
1 parent 0ecf06b commit 4c526a0

File tree

1 file changed

+12
-3
lines changed
  • tools/src/main/python/opengrok_tools

1 file changed

+12
-3
lines changed

tools/src/main/python/opengrok_tools/sync.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"""
2828

2929
import argparse
30+
import fnmatch
3031
import logging
3132
import multiprocessing
3233
import os
@@ -152,7 +153,8 @@ def main():
152153
parser.add_argument('-i', '--ignore_errors', nargs='*',
153154
help='ignore errors from these projects')
154155
parser.add_argument('--ignore_project', nargs='+',
155-
help='do not process given project(s)')
156+
help='do not process given project(s). '
157+
'The project name can be fnmatch-like pattern')
156158
parser.add_argument('-c', '--config', required=True,
157159
help='config file in JSON/YAML format')
158160
parser.add_argument('-U', '--uri', default='http://localhost:8080/source',
@@ -273,8 +275,15 @@ def main():
273275
ignored_projects.extend(args.ignore_project)
274276

275277
if ignored_projects:
276-
dirs_to_process = list(set(dirs_to_process) - set(ignored_projects))
277-
logger.debug("Removing projects: {}".format(ignored_projects))
278+
logger.debug("Removing projects based on the list: {}".format(ignored_projects))
279+
filtered_dirs = set(dirs_to_process)
280+
for dir in dirs_to_process:
281+
for ignore_pattern in ignored_projects:
282+
if fnmatch.fnmatchcase(dir, ignore_pattern):
283+
logger.debug(f"project {dir} matched {ignore_pattern} => removing")
284+
filtered_dirs.remove(dir)
285+
286+
dirs_to_process = list(filtered_dirs)
278287

279288
logger.debug("directories to process: {}".format(dirs_to_process))
280289

0 commit comments

Comments
 (0)