Bug 1281570 - Provide recommendations to fix typos when using 'mach try'. r=chmanchester

MozReview-Commit-ID: HIx5QevA3Iy
This commit is contained in:
Jared Wein 2016-06-24 21:36:39 -04:00
Родитель 26648ad110
Коммит 568b6e3746
2 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -485,6 +485,7 @@ class JsapiTestsCommand(MachCommandBase):
return jsapi_tests_result
def autotry_parser():
print("mach try is under development, please file bugs blocking 1149670.")
from autotry import arg_parser
return arg_parser()
@ -614,8 +615,6 @@ class PushToTry(MachCommandBase):
from mozbuild.testing import TestResolver
from autotry import AutoTry
print("mach try is under development, please file bugs blocking 1149670.")
resolver_func = lambda: self._spawn(TestResolver)
at = AutoTry(self.topsrcdir, resolver_func, self._mach_context)

Просмотреть файл

@ -9,16 +9,29 @@ import re
import subprocess
import sys
import which
import difflib
from collections import defaultdict
import ConfigParser
def validate_choices(values, choices):
valid = True
for value in values:
if value not in choices:
print 'Invalid choice {v!r}. Allowed choices: {c!r}'.format(v=value, c=choices)
sys.exit(1)
corrections = difflib.get_close_matches(value, choices)
if len(corrections) == 0:
print 'Potentially invalid choice {v!r}. Neither the requested value nor a similar value was found.'.format(v=value)
print 'List of possible values: {c!r}'.format(c=choices)
result = raw_input('Are you sure you want to continue? [y/N] ').strip()
if not 'y' in result.lower():
valid = False
elif corrections[0] == value:
continue
else:
valid = False
print 'Invalid choice {v!r}. Some suggestions (limit three): {c!r}?'.format(v=value, c=corrections)
if not valid:
sys.exit(1)
class ValidatePlatforms(argparse.Action):
def __call__(self, parser, args, values, option_string=None):