mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[git_auth] Add _url_shortname helper
Breaking out independent chunks from a larger CL Bug: b/401338175 Change-Id: I0b439596fb613355cb33b4b1d2a0481489d7c0c3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6345630 Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Commit-Queue: Allen Li <ayatane@chromium.org>
This commit is contained in:
16
git_auth.py
16
git_auth.py
@@ -64,10 +64,7 @@ class ConfigChanger(object):
|
||||
# Example: chromium
|
||||
parts: urllib.parse.SplitResult = urllib.parse.urlsplit(
|
||||
self._remote_url)
|
||||
name: str = parts.netloc.split('.')[0]
|
||||
if name.endswith('-review'):
|
||||
name = name[:-len('-review')]
|
||||
return name
|
||||
return _url_shortname(parts)
|
||||
|
||||
@functools.cached_property
|
||||
def _base_url(self) -> str:
|
||||
@@ -315,3 +312,14 @@ def ClearRepoConfig(cwd: str, cl: git_cl.Changelist) -> None:
|
||||
c = ConfigChanger.new_from_env(cwd, cl)
|
||||
c.mode = ConfigMode.NO_AUTH
|
||||
c.apply(cwd)
|
||||
|
||||
|
||||
def _url_shortname(parts: urllib.parse.SplitResult) -> str:
|
||||
"""Format URL as Gerrit host shortname.
|
||||
|
||||
Example: chromium
|
||||
"""
|
||||
name: str = parts.netloc.split('.')[0]
|
||||
if name.endswith('-review'):
|
||||
name = name[:-len('-review')]
|
||||
return name
|
||||
|
||||
Reference in New Issue
Block a user