Bug 1753701: Always default to `--outgoing`/`--workdir` in `./mach lint` r=ahal

Tweaks `./mach lint` behaviour to always fall back to only linting files
that have changed according to VCS - previously, this only happened if
no linter was provided.

Adjusts "am I at $topsrcdir" check to use `pathlib` to avoid mismatches
due to inconsistent capitalization or slash direction.

Updates CI references to explicitly provide `*` as the path to avoid
the only-lint-files-changed restriction.

Differential Revision: https://phabricator.services.mozilla.com/D137870
This commit is contained in:
Mitchell Hentges 2022-02-04 21:48:59 +00:00
Родитель f7c06a6a88
Коммит 951485daa3
2 изменённых файлов: 4 добавлений и 8 удалений

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

@ -5,6 +5,7 @@
import os
import sys
from argparse import REMAINDER, SUPPRESS, ArgumentParser
from pathlib import Path
from mozlint.errors import NoValidLinter
from mozlint.formatters import all_formatters
@ -360,12 +361,7 @@ def run(
return 1
paths = lint.linters[0]["local_exclude"]
if (
not linters
and not paths
and os.getcwd() == lint.root
and not (outgoing or workdir)
):
if not paths and Path.cwd() == Path(lint.root) and not (outgoing or workdir):
print(
"warning: linting the entire repo takes a long time, using --outgoing and "
"--workdir instead. If you want to lint the entire repo, run `./mach lint .`"

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

@ -105,7 +105,7 @@ eslint:
cp -r /build/node_modules_eslint node_modules &&
ln -s ../tools/lint/eslint/eslint-plugin-mozilla node_modules &&
ln -s ../tools/lint/eslint/eslint-plugin-spidermonkey-js node_modules &&
./mach lint -v -l eslint -f treeherder -f json:/builds/worker/mozlint.json
./mach lint -v -l eslint -f treeherder -f json:/builds/worker/mozlint.json *
when:
files-changed:
# Files that are likely audited.
@ -482,7 +482,7 @@ fluent-lint:
treeherder:
symbol: l10n(fluent)
run:
mach: lint --linter fluent-lint -f treeherder -f json:/builds/worker/mozlint.json
mach: lint --linter fluent-lint -f treeherder -f json:/builds/worker/mozlint.json *
when:
files-changed:
- '**/*.ftl'