blob: 5b95d51b6d445e29440f4f1bef3e67b78e5de7c5 [file] [log] [blame] [edit]
#!/usr/bin/env vpython3
# 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')
ENABLE_CLANG_TIDY = os.environ.get('PRE_PUSH_CLANG_TIDY')
def GetDartBin():
dart_bin = os.path.join(SRC_ROOT, 'flutter', 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin')
if not os.path.exists(dart_bin):
dart_bin = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'bin')
return dart_bin
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(GetDartBin(), 'dart'),
'--disable-dart-dev',
os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'),
] + githook_args + [
'pre-push',
] + argv[1:], cwd=SRC_ROOT)
return result.returncode
if __name__ == '__main__':
sys.exit(Main(sys.argv))