Skip to content

Commit b24f42f

Browse files
author
Oren Cohen
committed
Move regex to the using function
1 parent bd5d059 commit b24f42f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tools/importer/importer.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
from tools.utils import delete_dir_files, mkdir, copy_file
3434

3535
rel_log = logging.getLogger("Importer")
36-
cherry_pick_re = re.compile(
37-
'\s*\(cherry picked from commit (([0-9]|[a-f]|[A-F])+)\)')
3836

3937

4038
class StoreDir(argparse.Action):
@@ -184,13 +182,13 @@ def get_last_cherry_pick_sha():
184182
get_commit = ['git', '-C', ROOT, 'log', '-n', '1']
185183
_, output = run_cmd_with_output(get_commit, exit_on_failure=True)
186184

187-
lines = output.splitlines()
188-
lines.reverse()
189-
for line in lines:
190-
match = cherry_pick_re.match(line)
191-
if match:
192-
return match.group(1)
193-
return None
185+
shas = re.findall(
186+
pattern='^\s*\(cherry picked from commit ([0-9a-fA-F]+)\)$',
187+
string=output,
188+
flags=re.MULTILINE
189+
)
190+
191+
return shas[-1] if shas else None
194192

195193

196194
def normalize_commit_sha(sha_lst):

0 commit comments

Comments
 (0)