зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1357238 - Allow apostrophes in try commit messages r=dustin
This copies the behavior of mozilla-taskcluster when it submits try pushes. This will allow us to eventually stop using mozilla-taskcluster. MozReview-Commit-ID: J9zC92AE7HZ --HG-- extra : rebase_source : 36575ef1fa5c43b6b6d5c0243c323af69e4ebd23
This commit is contained in:
Родитель
7d791c9ebe
Коммит
835902dbb5
|
@ -100,6 +100,11 @@ class TestTryOptionSyntax(unittest.TestCase):
|
|||
self.assertEqual(tos.build_types, [])
|
||||
self.assertEqual(tos.jobs, None)
|
||||
|
||||
def test_apostrophe_in_message(self):
|
||||
"apostrophe does not break parsing"
|
||||
tos = TryOptionSyntax('Increase spammy log\'s log level. try: -b do', graph_with_jobs)
|
||||
self.assertEqual(sorted(tos.build_types), ['debug', 'opt'])
|
||||
|
||||
def test_b_do(self):
|
||||
"-b do should produce both build_types"
|
||||
tos = TryOptionSyntax('try: -b do', graph_with_jobs)
|
||||
|
|
|
@ -194,20 +194,18 @@ def escape_whitespace_in_brackets(input_str):
|
|||
return result
|
||||
|
||||
|
||||
def find_try_idx(message):
|
||||
def split_try_msg(message):
|
||||
try:
|
||||
try_idx = message.index('try:')
|
||||
except ValueError:
|
||||
return []
|
||||
message = message[try_idx:].split('\n')[0]
|
||||
# shlex used to ensure we split correctly when giving values to argparse.
|
||||
parts = shlex.split(escape_whitespace_in_brackets(message))
|
||||
try_idx = None
|
||||
for idx, part in enumerate(parts):
|
||||
if part == TRY_DELIMITER:
|
||||
try_idx = idx
|
||||
break
|
||||
|
||||
return try_idx, parts
|
||||
return shlex.split(escape_whitespace_in_brackets(message))
|
||||
|
||||
|
||||
def parse_message(message):
|
||||
try_idx, parts = find_try_idx(message)
|
||||
parts = split_try_msg(message)
|
||||
|
||||
# Argument parser based on try flag flags
|
||||
parser = argparse.ArgumentParser()
|
||||
|
@ -240,7 +238,6 @@ def parse_message(message):
|
|||
|
||||
# In order to run test jobs multiple times
|
||||
parser.add_argument('--rebuild', dest='trigger_tests', type=int, default=1)
|
||||
parts = parts[try_idx:] if try_idx is not None else []
|
||||
args, _ = parser.parse_known_args(parts)
|
||||
return args
|
||||
|
||||
|
@ -290,8 +287,8 @@ class TryOptionSyntax(object):
|
|||
self.tag = None
|
||||
self.no_retry = False
|
||||
|
||||
try_idx, _ = find_try_idx(message)
|
||||
if try_idx is None:
|
||||
parts = split_try_msg(message)
|
||||
if not parts:
|
||||
return None
|
||||
|
||||
args = parse_message(message)
|
||||
|
|
Загрузка…
Ссылка в новой задаче