#!/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')


def Main(argv):
  result = subprocess.run([
    os.path.join(DART_BIN, 'dart'),
    '--disable-dart-dev',
    os.path.join(FLUTTER_DIR, 'tools', 'githooks', 'bin', 'main.dart'),
    '--flutter',
    FLUTTER_DIR,
    'pre-push',
  ], cwd=SRC_ROOT)
  return result.returncode


if __name__ == '__main__':
    sys.exit(Main(sys.argv))
