Use regex to find cherry-pick message

pull/10505/head
Oren Cohen 2019-04-28 23:44:18 +03:00
parent 3273edba8d
commit 09af58fad5
No known key found for this signature in database
GPG Key ID: 6F54A3184C6F8FF9
1 changed files with 11 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import sys
import subprocess
import logging
import argparse
import re
from os.path import dirname, abspath, join, isfile, normpath
# Be sure that the tools directory is in the search path
@ -30,6 +31,9 @@ sys.path.insert(0, ROOT)
from tools.utils import delete_dir_files, mkdir, copy_file
cherry_pick_re = re.compile(
'\s*\(cherry picked from commit (([0-9]|[a-f]|[A-F])+)\)')
def del_file(name):
""" Delete the file in RTOS/CMSIS/features directory of mbed-os
@ -150,11 +154,14 @@ def get_last_cherry_pick_sha(branch):
sha = None
get_commit = ['git', 'log', '-n', '1']
_, output = run_cmd_with_output(get_commit, exit_on_failure=True)
lines = output.split('\n')
lines = output.splitlines()
lines.reverse()
for line in lines:
if 'cherry picked from' in line:
sha = line.split(' ')[-1][:-1]
return sha
match = cherry_pick_re.match(line)
if match:
return match.group(1)
return None
def normalize_commit_sha(sha_lst):