Bug 1645869 - mozlint/rustfmt: make the check relevant r=undef1nd

The version check is done above. So, it will fail there.
Move the binary check earlier to have a better error message

+ simplify the code

Differential Revision: https://phabricator.services.mozilla.com/D79725
This commit is contained in:
Sylvestre Ledru 2020-06-17 07:16:09 +00:00
Родитель 5ad439fc99
Коммит fc28509901
1 изменённых файлов: 8 добавлений и 8 удалений

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

@ -125,8 +125,7 @@ def get_rustfmt_version(binary):
output = e.output
version = re.findall(r'\d.\d+.\d+', output)[0]
version = StrictVersion(version)
return version
return StrictVersion(version)
def lint(paths, config, fix=None, **lintargs):
@ -139,6 +138,13 @@ def lint(paths, config, fix=None, **lintargs):
return []
binary = get_rustfmt_binary()
if not binary:
print(RUSTFMT_NOT_FOUND)
if "MOZ_AUTOMATION" in os.environ:
return 1
return []
min_version_str = config.get('min_rustfmt_version')
min_version = StrictVersion(min_version_str)
actual_version = get_rustfmt_version(binary)
@ -152,12 +158,6 @@ def lint(paths, config, fix=None, **lintargs):
print(RUSTFMT_WRONG_VERSION.format(version=min_version_str))
return 1
if not binary:
print(RUSTFMT_NOT_FOUND)
if "MOZ_AUTOMATION" in os.environ:
return 1
return []
cmd_args = [binary]
if not fix:
cmd_args.append("--check")