aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2024-04-16 08:53:24 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-04-16 20:07:14 +0000
commit8a26cd3ee163f5db801efd68deb70fc6f51cc25a (patch)
tree7b39a119a95b7250f360fc228e98e34a54735621
parent54e65f7949aca046aaa703514913ff5cd50f1626 (diff)
downloadtoolchain-utils-8a26cd3ee163f5db801efd68deb70fc6f51cc25a.tar.gz
cros_utils: add support for parsing for internal CL uploads
BUG=b:333462347 TEST=Unittests Change-Id: Ia6abfee1465465784c2934a4ac64e878ac577d6c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5458262 Reviewed-by: Jordan Abrahams-Whitehead <ajordanr@google.com> Tested-by: George Burgess <gbiv@chromium.org> Commit-Queue: George Burgess <gbiv@chromium.org>
-rw-r--r--cros_utils/git_utils.py5
-rwxr-xr-xcros_utils/git_utils_test.py39
2 files changed, 41 insertions, 3 deletions
diff --git a/cros_utils/git_utils.py b/cros_utils/git_utils.py
index c4245280..d8c11d0a 100644
--- a/cros_utils/git_utils.py
+++ b/cros_utils/git_utils.py
@@ -21,7 +21,10 @@ REVIEWER_DETECTIVE = "c-compiler-chrome@google.com"
def _parse_cls_from_upload_output(upload_output: str) -> List[int]:
"""Returns the CL number in the given upload output."""
id_regex = re.compile(
- r"^remote:\s+https://chromium-review\S+/\+/(\d+)\s", re.MULTILINE
+ r"^remote:\s+https://"
+ r"(?:chromium|chrome-internal)"
+ r"-review\S+/\+/(\d+)\s",
+ re.MULTILINE,
)
results = id_regex.findall(upload_output)
diff --git a/cros_utils/git_utils_test.py b/cros_utils/git_utils_test.py
index 2edf1591..f6060a7b 100755
--- a/cros_utils/git_utils_test.py
+++ b/cros_utils/git_utils_test.py
@@ -11,7 +11,7 @@ from cros_utils import git_utils
# pylint: disable=protected-access
-GERRIT_OUTPUT_WITH_ONE_CL = """
+GERRIT_OUTPUT_WITH_ONE_CL = r"""
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 128 threads
@@ -29,7 +29,7 @@ To https://chromium.googlesource.com/chromiumos/third_party/toolchain-utils
* [new reference] HEAD -> refs/for/main
"""
-GERRIT_OUTPUT_WITH_TWO_CLS = """
+GERRIT_OUTPUT_WITH_TWO_CLS = r"""
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 128 threads
@@ -49,6 +49,33 @@ To https://chromium.googlesource.com/chromiumos/third_party/toolchain-utils
"""
+GERRIT_OUTPUT_WITH_INTERNAL_CL = r"""
+Upload project manifest-internal/ to remote branch refs/heads/main:
+ branch DO-NOT-COMMIT ( 1 commit, Tue Apr 16 08:51:25 2024 -0600):
+ 456aadd0 DO NOT COMMIT
+to https://chrome-internal-review.googlesource.com (y/N)? <--yes>
+Enumerating objects: 5, done.
+Counting objects: 100% (5/5), done.
+Delta compression using up to 128 threads
+Compressing objects: 100% (3/3), done.
+Writing objects: 100% (3/3), 334 bytes | 334.00 KiB/s, done.
+Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
+remote: Resolving deltas: 100% (2/2)
+remote: Waiting for private key checker: 1/1 objects left
+remote: Processing changes: refs: 1, new: 1, done
+remote:
+remote: SUCCESS
+remote:
+remote: https://chrome-internal-review.googlesource.com/c/chromeos/manifest-internal/+/7190037 DO NOT COMMIT [NEW]
+remote:
+To https://chrome-internal-review.googlesource.com/chromeos/manifest-internal
+ * [new reference] DO-NOT-COMMIT -> refs/for/main
+
+----------------------------------------------------------------------
+[OK ] manifest-internal/ DO-NOT-COMMIT
+"""
+
+
class Test(unittest.TestCase):
"""Tests for git_utils."""
@@ -68,6 +95,14 @@ class Test(unittest.TestCase):
[5375204, 5375205],
)
+ def test_cl_parsing_works_with_internal_cl(self):
+ self.assertEqual(
+ git_utils._parse_cls_from_upload_output(
+ GERRIT_OUTPUT_WITH_INTERNAL_CL
+ ),
+ [7190037],
+ )
+
if __name__ == "__main__":
unittest.main()