aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Burgess IV <gbiv@google.com>2024-04-12 13:07:54 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-04-15 14:02:37 +0000
commit5910e9f15c2e2f8699e54fc04277ff09d03d016a (patch)
tree09cced6bb354ef18142282bd2d8558cc84f0c77c
parent977ad131c629f8c7b69b76537cfc60fa8546dddb (diff)
downloadtoolchain-utils-5910e9f15c2e2f8699e54fc04277ff09d03d016a.tar.gz
llvm_tools: add internal CL support to cros_cls
Some llvm-next CLs (e.g., manifest updates) need to be internal. Supporting those here is straightforward. BUG=b:333462347 TEST=repo upload Change-Id: I6ca14cfce2e086743476fe0eb059b9172736707e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5450238 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--llvm_tools/cros_cls.py19
-rwxr-xr-xllvm_tools/cros_cls_test.py26
2 files changed, 39 insertions, 6 deletions
diff --git a/llvm_tools/cros_cls.py b/llvm_tools/cros_cls.py
index d0524b6d..d5b5ffa0 100644
--- a/llvm_tools/cros_cls.py
+++ b/llvm_tools/cros_cls.py
@@ -65,6 +65,7 @@ class ChangeListURL:
cl_id: int
patch_set: Optional[int] = None
+ internal: bool = False
@classmethod
def parse(cls, url: str) -> "ChangeListURL":
@@ -73,8 +74,9 @@ class ChangeListURL:
r"(?:https?://)?"
# Match either chromium-review or crrev, leaving the CL number and
# patch set as the next parts. These can be parsed in unison.
- r"(?:chromium-review\.googlesource\.com.*/\+/"
- r"|crrev\.com/c/)"
+ r"(chromium-review\.googlesource\.com.*/\+/"
+ r"|crrev\.com/[ci]/"
+ r"|chrome-internal-review\.googlesource\.com.*/\+/)"
# Match the CL number...
r"(\d+)"
# and (optionally) the patch-set, as well as consuming any of the
@@ -91,12 +93,16 @@ class ChangeListURL:
"crrev.com/c/${cl_number}/${patch_set_number}, and "
"chromium-review.googlesource.com/c/project/path/+/"
"${cl_number}/${patch_set_number}. The patch-set number is "
- "optional, and there may be a preceding http:// or https://."
+ "optional, and there may be a preceding http:// or https://. "
+ "Internal CL links are also supported."
)
- cl_id, maybe_patch_set = m.groups()
+ host, cl_id, maybe_patch_set = m.groups()
+ internal = host.startswith("chrome-internal-review") or host.startswith(
+ "crrev.com/i/"
+ )
if maybe_patch_set is not None:
maybe_patch_set = int(maybe_patch_set)
- return cls(int(cl_id), maybe_patch_set)
+ return cls(int(cl_id), maybe_patch_set, internal)
@classmethod
def parse_with_patch_set(cls, url: str) -> "ChangeListURL":
@@ -107,7 +113,8 @@ class ChangeListURL:
return result
def __str__(self):
- result = f"https://crrev.com/c/{self.cl_id}"
+ namespace = "i" if self.internal else "c"
+ result = f"https://crrev.com/{namespace}/{self.cl_id}"
if self.patch_set is not None:
result += f"/{self.patch_set}"
return result
diff --git a/llvm_tools/cros_cls_test.py b/llvm_tools/cros_cls_test.py
index fd4ed3ef..45efaf31 100755
--- a/llvm_tools/cros_cls_test.py
+++ b/llvm_tools/cros_cls_test.py
@@ -22,6 +22,21 @@ class TestChangeListURL(unittest.TestCase):
cros_cls.ChangeListURL(cl_id=123456, patch_set=None),
)
+ def test_parsing_long_form_internal_url(self):
+ self.assertEqual(
+ cros_cls.ChangeListURL.parse(
+ "chrome-internal-review.googlesource.com/c/chromeos/"
+ "manifest-internal/+/654321"
+ ),
+ cros_cls.ChangeListURL(cl_id=654321, patch_set=None, internal=True),
+ )
+
+ def test_parsing_short_internal_url(self):
+ self.assertEqual(
+ cros_cls.ChangeListURL.parse("crrev.com/i/654321"),
+ cros_cls.ChangeListURL(cl_id=654321, patch_set=None, internal=True),
+ )
+
def test_parsing_discards_http(self):
self.assertEqual(
cros_cls.ChangeListURL.parse("http://crrev.com/c/123456"),
@@ -106,6 +121,17 @@ class TestChangeListURL(unittest.TestCase):
"https://crrev.com/c/1234",
)
+ self.assertEqual(
+ str(
+ cros_cls.ChangeListURL(
+ cl_id=1234,
+ patch_set=2,
+ internal=True,
+ )
+ ),
+ "https://crrev.com/i/1234/2",
+ )
+
class Test(unittest.TestCase):
"""General tests for cros_cls."""