diff options
author | George Burgess IV <gbiv@google.com> | 2020-06-24 16:27:44 -0700 |
---|---|---|
committer | George Burgess <gbiv@chromium.org> | 2020-06-24 23:44:11 +0000 |
commit | 536aff5f6d015f840bafd6ea70774bbc6b3da6f3 (patch) | |
tree | 94820359797af86c9a703fd1d27e9547cb81b673 /llvm_tools/get_llvm_hash.py | |
parent | efb96d1a55f64e72489e219ea65d974e5468a753 (diff) | |
download | toolchain-utils-536aff5f6d015f840bafd6ea70774bbc6b3da6f3.tar.gz |
llvm_tools: fix up naming
This replaces `master` with `main` where possible, per the linked bug.
Since upstream LLVM has a `master` branch, and there appears to be
general support in FOSS for swapping to a different naming convention
(`main`), this also makes LLVM's upstream branch name into a constant
that we can easily flip if needed.
BUG=chromium:1099035
TEST=Unittests
Change-Id: I0844cfb4fec00f761e39b0443299daa918fa37ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2265047
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'llvm_tools/get_llvm_hash.py')
-rwxr-xr-x | llvm_tools/get_llvm_hash.py | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/llvm_tools/get_llvm_hash.py b/llvm_tools/get_llvm_hash.py index a5b5429e..4200cffe 100755 --- a/llvm_tools/get_llvm_hash.py +++ b/llvm_tools/get_llvm_hash.py @@ -17,7 +17,8 @@ import tempfile from contextlib import contextmanager import git_llvm_rev -from subprocess_helpers import CheckCommand, check_output +from subprocess_helpers import CheckCommand +from subprocess_helpers import check_output _LLVM_GIT_URL = ('https://chromium.googlesource.com/external/github.com/llvm' '/llvm-project') @@ -39,7 +40,7 @@ def GetVersionFrom(src_dir, git_hash): version = git_llvm_rev.translate_sha_to_rev( git_llvm_rev.LLVMConfig(remote='origin', dir=src_dir), git_hash) # Note: branches aren't supported - assert version.branch == 'master', version.branch + assert version.branch == git_llvm_rev.MAIN_BRANCH, version.branch return version.number @@ -59,7 +60,7 @@ def GetGitHashFrom(src_dir, version): return git_llvm_rev.translate_rev_to_sha( git_llvm_rev.LLVMConfig(remote='origin', dir=src_dir), - git_llvm_rev.Rev(branch='master', number=version)) + git_llvm_rev.Rev(branch=git_llvm_rev.MAIN_BRANCH, number=version)) @contextmanager @@ -85,13 +86,10 @@ def CreateTempLLVMRepo(temp_dir): """ abs_path_to_llvm_project_dir = GetAndUpdateLLVMProjectInLLVMTools() - - add_worktree_cmd = [ + CheckCommand([ 'git', '-C', abs_path_to_llvm_project_dir, 'worktree', 'add', '--detach', - temp_dir, 'master' - ] - - CheckCommand(add_worktree_cmd) + temp_dir, git_llvm_rev.MAIN_BRANCH + ]) try: yield temp_dir @@ -117,7 +115,7 @@ def GetAndUpdateLLVMProjectInLLVMTools(): Raises: ValueError: LLVM repo (in 'llvm-project-copy' dir.) has changes or failed to - checkout to master or failed to fetch from chromium mirror of LLVM. + checkout to main or failed to fetch from chromium mirror of LLVM. """ abs_path_to_llvm_tools_dir = os.path.dirname(os.path.abspath(__file__)) @@ -143,15 +141,11 @@ def GetAndUpdateLLVMProjectInLLVMTools(): raise ValueError('LLVM repo in %s has changes, please remove.' % abs_path_to_llvm_project_dir) - checkout_to_master_cmd = [ - 'git', '-C', abs_path_to_llvm_project_dir, 'checkout', 'master' - ] - - CheckCommand(checkout_to_master_cmd) - - update_master_cmd = ['git', '-C', abs_path_to_llvm_project_dir, 'pull'] - - CheckCommand(update_master_cmd) + CheckCommand([ + 'git', '-C', abs_path_to_llvm_project_dir, 'checkout', + git_llvm_rev.MAIN_BRANCH + ]) + CheckCommand(['git', '-C', abs_path_to_llvm_project_dir, 'pull']) return abs_path_to_llvm_project_dir @@ -298,14 +292,9 @@ class LLVMHash(object): def GetTopOfTrunkGitHash(self): """Gets the latest git hash from top of trunk of LLVM.""" - path_to_master_branch = 'refs/heads/master' - - llvm_tot_git_hash_cmd = [ - 'git', 'ls-remote', _LLVM_GIT_URL, path_to_master_branch - ] - - llvm_tot_git_hash = check_output(llvm_tot_git_hash_cmd) - + path_to_main_branch = 'refs/heads/master' + llvm_tot_git_hash = check_output( + ['git', 'ls-remote', _LLVM_GIT_URL, path_to_main_branch]) return llvm_tot_git_hash.rstrip().split()[0] |