Disable clang-tidy pre-push hook by default (flutter/engine#35207)
This commit is contained in:
@@ -19,6 +19,10 @@ Future<int> run(List<String> args) async {
|
|||||||
|
|
||||||
// Add top-level arguments.
|
// Add top-level arguments.
|
||||||
runner.argParser
|
runner.argParser
|
||||||
|
..addFlag(
|
||||||
|
'enable-clang-tidy',
|
||||||
|
help: 'Enable running clang-tidy on changed files.',
|
||||||
|
)
|
||||||
..addOption(
|
..addOption(
|
||||||
'flutter',
|
'flutter',
|
||||||
abbr: 'f',
|
abbr: 'f',
|
||||||
|
|||||||
@@ -20,10 +20,18 @@ class PrePushCommand extends Command<bool> {
|
|||||||
Future<bool> run() async {
|
Future<bool> run() async {
|
||||||
final Stopwatch sw = Stopwatch()..start();
|
final Stopwatch sw = Stopwatch()..start();
|
||||||
final bool verbose = globalResults!['verbose']! as bool;
|
final bool verbose = globalResults!['verbose']! as bool;
|
||||||
|
final bool enableClangTidy = globalResults!['enable-clang-tidy']! as bool;
|
||||||
final String flutterRoot = globalResults!['flutter']! as String;
|
final String flutterRoot = globalResults!['flutter']! as String;
|
||||||
|
|
||||||
|
if (!enableClangTidy) {
|
||||||
|
print('The clang-tidy check is disabled. To enable set the environment '
|
||||||
|
'variable PRE_PUSH_CLANG_TIDY to any value.');
|
||||||
|
}
|
||||||
|
|
||||||
final List<bool> checkResults = <bool>[
|
final List<bool> checkResults = <bool>[
|
||||||
await _runFormatter(flutterRoot, verbose),
|
await _runFormatter(flutterRoot, verbose),
|
||||||
await _runClangTidy(flutterRoot, verbose),
|
if (enableClangTidy)
|
||||||
|
await _runClangTidy(flutterRoot, verbose),
|
||||||
];
|
];
|
||||||
sw.stop();
|
sw.stop();
|
||||||
io.stdout.writeln('pre-push checks finished in ${sw.elapsed}');
|
io.stdout.writeln('pre-push checks finished in ${sw.elapsed}');
|
||||||
@@ -51,7 +59,8 @@ class PrePushCommand extends Command<bool> {
|
|||||||
'compile_commands.json',
|
'compile_commands.json',
|
||||||
));
|
));
|
||||||
if (!compileCommands.existsSync()) {
|
if (!compileCommands.existsSync()) {
|
||||||
io.stderr.writeln('clang-tidy requires a fully built host_debug or host_debug_unopt build directory');
|
io.stderr.writeln('clang-tidy requires a fully built host_debug or '
|
||||||
|
'host_debug_unopt build directory');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,15 +15,24 @@ import sys
|
|||||||
SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
SRC_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
||||||
FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter')
|
FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter')
|
||||||
DART_BIN = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin')
|
DART_BIN = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin')
|
||||||
|
ENABLE_CLANG_TIDY = os.environ.get('PRE_PUSH_CLANG_TIDY')
|
||||||
|
|
||||||
def Main(argv):
|
def Main(argv):
|
||||||
|
githook_args = [
|
||||||
|
'--flutter',
|
||||||
|
FLUTTER_DIR,
|
||||||
|
]
|
||||||
|
|
||||||
|
if ENABLE_CLANG_TIDY is not None:
|
||||||
|
githook_args += [
|
||||||
|
'--enable-clang-tidy',
|
||||||
|
]
|
||||||
|
|
||||||
result = subprocess.run([
|
result = subprocess.run([
|
||||||
os.path.join(DART_BIN, 'dart'),
|
os.path.join(DART_BIN, 'dart'),
|
||||||
'--disable-dart-dev',
|
'--disable-dart-dev',
|
||||||
os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'),
|
os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'),
|
||||||
'--flutter',
|
] + githook_args + [
|
||||||
FLUTTER_DIR,
|
|
||||||
'pre-push',
|
'pre-push',
|
||||||
], cwd=SRC_ROOT)
|
], cwd=SRC_ROOT)
|
||||||
return result.returncode
|
return result.returncode
|
||||||
|
|||||||
Reference in New Issue
Block a user