blob: 1e3e7c5f2ca155e00afeb496c2afcf96d9e50df2 [file] [log] [blame]
Ian Zernydcb172e2022-02-22 15:36:45 +01001#!/usr/bin/env python3
Søren Gjesse1c115b52019-08-14 12:43:57 +02002# Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
6import utils
7import subprocess
8
9def GitClone(url, checkout_dir):
10 cmd = ['git', 'clone', url, checkout_dir]
11 utils.PrintCmd(cmd)
12 return subprocess.check_call(cmd)
13
Rico Wind1b52acf2021-03-21 12:36:55 +010014def GetHeadRevision(checkout_dir, use_main=False):
15 revision_from = 'origin/main' if use_main else 'HEAD'
Rico Wind1cd21b02019-08-14 13:26:21 +020016 cmd = ['git', 'rev-parse', revision_from]
Søren Gjesse1c115b52019-08-14 12:43:57 +020017 utils.PrintCmd(cmd)
Rico Wind1cd21b02019-08-14 13:26:21 +020018 with utils.ChangedWorkingDirectory(checkout_dir):
Søren Gjesse1c115b52019-08-14 12:43:57 +020019 return subprocess.check_output(cmd).strip()