Debian Codegraph @

third_party/python/mozilla_repo_urls/mozilla_repo_urls/result.py

raw
1 import giturlparse
2
3 _DOT_GIT_SUFFIX = ".git"
4
5
6 class RepoUrlParsed(giturlparse.result.GitUrlParsed):
7 @property
8 def hgmo(self) -> bool:
9 return self.platform == "hgmo"
10
11 @property
12 def git_cinnabar(self) -> bool:
13 # https://github.com/glandium/git-cinnabar
14 return len(self.protocols) > 0 and self.protocols[0].startswith("hg::")
15
16 @property
17 def repo_name(self) -> str:
18 return self.repo_path.split("/")[-1]
19
20 @property
21 def repo_path(self) -> str:
22 repo_path = (
23 self.pathname[: -len(_DOT_GIT_SUFFIX)]
24 if self.pathname.endswith(_DOT_GIT_SUFFIX)
25 else self.pathname
26 )
27 return repo_path.strip("/")
28
29 @property
30 def repo_type(self) -> str:
31 return "hg" if self.platform == "hgmo" and not self.git_cinnabar else "git"
32
33 @property
34 def taskcluster_role_prefix(self) -> str:
35 return f"repo:{self.host}/{self.repo_path}"