witty-crayon-22786
05/24/2016, 11:35 PMrough-minister-58256
05/24/2016, 11:40 PMwitty-crayon-22786
05/25/2016, 12:22 AMrough-minister-58256
05/25/2016, 1:17 AMpathspec
. I came up with a working glob->regex converter thats actually fairly simple w/ test coverage.rough-minister-58256
05/25/2016, 1:17 AMdef glob_to_regex(glob):
"""Given a glob pattern, return a regex that will match it's path relative to the buildroot.
:param string glob: The glob pattern.
:returns: A regex string that will match a relative glob path with no leading `/`.
"""
replacement_map = (('?', r'.'),
('.', r'[.]'),
('**/', r'(?:.*/)?'),
('*', r'[^/]*'))
for from_pattern, to_pattern in replacement_map:
glob = glob.replace(from_pattern, to_pattern)
# Treat trailing slashes as "the dir and everything beneath it".
if glob.endswith('/'):
glob = r'{}(/.*|$)'.format(glob[:-1])
if glob.startswith('/'):
glob = r'^{}'.format(glob[1:])
return glob
rough-minister-58256
05/25/2016, 1:18 AMrough-minister-58256
05/25/2016, 1:20 AMrough-minister-58256
05/25/2016, 1:21 AM>>> pathspec.GitIgnorePattern('/dist/').regex.pattern
'^dist/.*$’
rough-minister-58256
05/25/2016, 1:22 AMrough-minister-58256
05/25/2016, 1:56 AMwitty-crayon-22786
05/25/2016, 3:23 AMwitty-crayon-22786
05/25/2016, 3:24 AMwitty-crayon-22786
05/25/2016, 3:41 AMrough-minister-58256
05/25/2016, 7:57 AMbillowy-beach-68498
05/25/2016, 6:22 PMwitty-crayon-22786
05/25/2016, 8:26 PMrough-minister-58256
05/25/2016, 8:27 PMrough-minister-58256
05/25/2016, 9:19 PM—enable-engine
vs —enable-v2-engine
comment - do folks have any opinions on that?rough-minister-58256
05/25/2016, 9:20 PMrough-minister-58256
05/25/2016, 9:20 PMrough-minister-58256
05/25/2016, 9:21 PMwitty-crayon-22786
05/25/2016, 9:21 PMwitty-crayon-22786
05/25/2016, 9:22 PMrough-minister-58256
05/25/2016, 9:23 PMrough-minister-58256
05/25/2016, 9:23 PMrough-minister-58256
05/25/2016, 9:23 PMrough-minister-58256
05/25/2016, 9:26 PMbillowy-beach-68498
05/25/2016, 9:28 PMbillowy-beach-68498
05/25/2016, 9:29 PMwitty-crayon-22786
05/25/2016, 9:30 PM