blob: 72485e148aba538d434400e76af29b34ad76e02f [file] [log] [blame]
Søren Gjesse1c115b52019-08-14 12:43:57 +02001#!/usr/bin/env python
2# 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 Wind1cd21b02019-08-14 13:26:21 +020014def GetHeadRevision(checkout_dir, use_master=False):
15 revision_from = 'origin/master' if use_master else 'HEAD'
16 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()