blob: 4e10ce870add57244a2d0acf74cffd04e6852b4f [file] [log] [blame] [edit]
#!/usr/bin/env python3
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
'''
Runs the pre-push githooks.
'''
import os
import subprocess
import sys
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')
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):
githook_args = [
'--flutter',
FLUTTER_DIR,
]
if ENABLE_CLANG_TIDY is not None:
githook_args += [
'--enable-clang-tidy',
]
result = subprocess.run([
os.path.join(DART_BIN, 'dart'),
'--disable-dart-dev',
os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'),
] + githook_args + [
'pre-push',
], cwd=SRC_ROOT)
return result.returncode
if __name__ == '__main__':
sys.exit(Main(sys.argv))