blob: 9d9c6bd1f3db6c2e933f4d6783546676bfae15ba [file] [log] [blame] [edit]
#!/usr/bin/env python
# Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import utils
import subprocess
def GitClone(url, checkout_dir):
cmd = ['git', 'clone', url, checkout_dir]
utils.PrintCmd(cmd)
return subprocess.check_call(cmd)
def GetHeadRevision(checkout_dir, use_main=False):
revision_from = 'origin/main' if use_main else 'HEAD'
cmd = ['git', 'rev-parse', revision_from]
utils.PrintCmd(cmd)
with utils.ChangedWorkingDirectory(checkout_dir):
return subprocess.check_output(cmd).strip()