diff options
-rw-r--r-- | cros_utils/git_utils.py | 5 | ||||
-rwxr-xr-x | cros_utils/git_utils_test.py | 39 |
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() |