[~] Refactor
This commit is contained in:
parent
2b45eea937
commit
f99cf5d304
@ -33,10 +33,50 @@ def f5_1(pattern, flags, info):
|
|||||||
#print([pattern, flags, info])
|
#print([pattern, flags, info])
|
||||||
completed_process = None
|
completed_process = None
|
||||||
|
|
||||||
|
options = dict(
|
||||||
|
recursive=False,
|
||||||
|
ext=[],
|
||||||
|
)
|
||||||
|
|
||||||
|
#print('fuck')
|
||||||
|
if b'r' in flags:
|
||||||
|
while True:
|
||||||
|
ext_m = re.compile('^.([^\,]+),(.*)$').match(pattern)
|
||||||
|
|
||||||
|
if pattern[:3] in [r'\r,']:
|
||||||
|
options['recursive'] = True
|
||||||
|
pattern = pattern[3:]
|
||||||
|
elif not ext_m is None:
|
||||||
|
options['ext'].append(
|
||||||
|
ext_m[1]
|
||||||
|
)
|
||||||
|
pattern = ext_m[2]
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
print([flags, pattern, options,])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
completed_process = subprocess.run([
|
git_cmd = [
|
||||||
'git', 'grep', '-n', '-P', pattern,
|
'git', 'grep',
|
||||||
], capture_output=True,)
|
'-n',
|
||||||
|
]
|
||||||
|
|
||||||
|
if options['recursive']:
|
||||||
|
git_cmd.append('--recurse-submodules')
|
||||||
|
|
||||||
|
git_cmd.extend(['-P', pattern])
|
||||||
|
|
||||||
|
if len(options['ext']) > 0:
|
||||||
|
git_cmd.extend(['--', *[
|
||||||
|
'**/*%s' % o
|
||||||
|
for o in options['ext']
|
||||||
|
]])
|
||||||
|
|
||||||
|
completed_process = subprocess.run(
|
||||||
|
git_cmd,
|
||||||
|
capture_output=True,
|
||||||
|
)
|
||||||
assert (
|
assert (
|
||||||
completed_process.returncode == 0 or
|
completed_process.returncode == 0 or
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user