Søren Gjesse | 1c115b5 | 2019-08-14 12:43:57 +0200 | [diff] [blame] | 1 | #!/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 | |
| 6 | import utils |
| 7 | import subprocess |
| 8 | |
| 9 | def GitClone(url, checkout_dir): |
| 10 | cmd = ['git', 'clone', url, checkout_dir] |
| 11 | utils.PrintCmd(cmd) |
| 12 | return subprocess.check_call(cmd) |
| 13 | |
Rico Wind | 1cd21b0 | 2019-08-14 13:26:21 +0200 | [diff] [blame] | 14 | def 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 Gjesse | 1c115b5 | 2019-08-14 12:43:57 +0200 | [diff] [blame] | 17 | utils.PrintCmd(cmd) |
Rico Wind | 1cd21b0 | 2019-08-14 13:26:21 +0200 | [diff] [blame] | 18 | with utils.ChangedWorkingDirectory(checkout_dir): |
Søren Gjesse | 1c115b5 | 2019-08-14 12:43:57 +0200 | [diff] [blame] | 19 | return subprocess.check_output(cmd).strip() |