Correct file search implementation
The behavior for searching "file" more closely matches the documented behavior for "path". Implement "path" the same as "file", then update "file" so that the non-regex form matches path components. Change-Id: I03bf6d5232472069ea288b1ce0fe955469791af1
This commit is contained in:
parent
6b794c03ee
commit
9105cbb232
|
@ -95,6 +95,7 @@ def SearchParser():
|
|||
| is_term
|
||||
| status_term
|
||||
| file_term
|
||||
| path_term
|
||||
| limit_term
|
||||
| op_term'''
|
||||
p[0] = p[1]
|
||||
|
@ -318,6 +319,18 @@ def SearchParser():
|
|||
|
||||
def p_file_term(p):
|
||||
'''file_term : OP_FILE string'''
|
||||
if p[2].startswith('^'):
|
||||
p[0] = and_(or_(func.matches(p[2], gertty.db.file_table.c.path),
|
||||
func.matches(p[2], gertty.db.file_table.c.old_path)),
|
||||
gertty.db.file_table.c.status is not None)
|
||||
else:
|
||||
file_re = '(^|.*/)%s(/.*|$)' % re.escape(p[2])
|
||||
p[0] = and_(or_(func.matches(file_re, gertty.db.file_table.c.path),
|
||||
func.matches(file_re, gertty.db.file_table.c.old_path)),
|
||||
gertty.db.file_table.c.status is not None)
|
||||
|
||||
def p_path_term(p):
|
||||
'''path_term : OP_PATH string'''
|
||||
if p[2].startswith('^'):
|
||||
p[0] = and_(or_(func.matches(p[2], gertty.db.file_table.c.path),
|
||||
func.matches(p[2], gertty.db.file_table.c.old_path)),
|
||||
|
|
|
@ -36,6 +36,7 @@ operators = {
|
|||
'message': 'OP_MESSAGE',
|
||||
'comment': 'OP_COMMENT',
|
||||
'file': 'OP_FILE',
|
||||
'path': 'OP_PATH',
|
||||
'has': 'OP_HAS',
|
||||
'is': 'OP_IS',
|
||||
'status': 'OP_STATUS',
|
||||
|
|
Loading…
Reference in New Issue