diff options
author | Jordan R Abrahams-Whitehead <ajordanr@google.com> | 2023-09-11 21:08:03 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-09-14 21:44:56 +0000 |
commit | d5bd646162df1e12c9fc99c30c07d52146b1f6ff (patch) | |
tree | 9a9169dca96288c1ead8ce9bba16b31301c0f56c /llvm_tools/git.py | |
parent | e7d3b21b16f9e08c9dedb1dd41cb6aeefc20ed06 (diff) | |
download | toolchain-utils-d5bd646162df1e12c9fc99c30c07d52146b1f6ff.tar.gz |
llvm_tools: update_chromeos_llvm_hash no_delete_branch
This adds two flags to `update_chromeos_llvm_hash`:
- --no_delete_branch: Don't delete the branch when we're done.
- --no_upload_changes: Don't upload things to gerrit.
Then updates the users of git.py so that these changes don't
break anything.
BUG=None
TEST=run_tests_for.py llvm_tools/*
TEST=./update_chromeos_llvm_hash.py \
--no_delete_branch \
--no_upload_changes \
--failure_mode=disable_patches \
--llvm_version 498229
Change-Id: Ibce18f79ebfb1bf5de99175faf33225e68d5435b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/4867272
Commit-Queue: Jordan Abrahams-Whitehead <ajordanr@google.com>
Tested-by: Jordan Abrahams-Whitehead <ajordanr@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'llvm_tools/git.py')
-rwxr-xr-x | llvm_tools/git.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/llvm_tools/git.py b/llvm_tools/git.py index 3bb702c9..fc3d9b38 100755 --- a/llvm_tools/git.py +++ b/llvm_tools/git.py @@ -12,6 +12,7 @@ import os import re import subprocess import tempfile +from typing import Iterable, Optional CommitContents = collections.namedtuple("CommitContents", ["url", "cl_number"]) @@ -73,15 +74,31 @@ def DeleteBranch(repo, branch): run_checked(["branch", "-q", "-D", branch]) +def CommitChanges(repo, commit_messages: Iterable[str]): + """Commit changes without uploading them.""" + if not os.path.isdir(repo): + raise ValueError("Invalid path provided: %s" % repo) + + # Create a git commit. + with tempfile.NamedTemporaryFile(mode="w+t", encoding="utf-8") as f: + f.write("\n".join(commit_messages)) + f.flush() + + subprocess.check_output(["git", "commit", "-F", f.name], cwd=repo) + + def UploadChanges( - repo, branch, commit_messages, reviewers=None, cc=None, wip=False + repo, + branch: str, + reviewers: Optional[Iterable[str]] = None, + cc: Optional[Iterable[str]] = None, + wip=False, ): """Uploads the changes in the specifed branch of the given repo for review. Args: repo: The absolute path to the repo where changes were made. branch: The name of the branch to upload. - commit_messages: A string of commit message(s) (i.e. '[message]' of the changes made. reviewers: A list of reviewers to add to the CL. cc: A list of contributors to CC about the CL. @@ -98,13 +115,6 @@ def UploadChanges( if not os.path.isdir(repo): raise ValueError("Invalid path provided: %s" % repo) - # Create a git commit. - with tempfile.NamedTemporaryFile(mode="w+t") as f: - f.write("\n".join(commit_messages)) - f.flush() - - subprocess.check_output(["git", "commit", "-F", f.name], cwd=repo) - # Upload the changes for review. git_args = [ "repo", |