git_auth: Organize helpers

Group URL returning helpers together

Bug: 419182970
Change-Id: Icec51bec8b0ce808d70c1eff7131933d1419719e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7173363
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
This commit is contained in:
Allen Li
2025-11-19 16:13:46 -08:00
committed by LUCI CQ
parent 573d5924ac
commit 375fb27dca

View File

@@ -813,6 +813,24 @@ def _url_gerrit_sso_url(parts: urllib.parse.SplitResult) -> str:
return f'sso://{_url_shortname(parts)}/'
def _url_host_url(parts: urllib.parse.SplitResult) -> str:
"""Format URL with host only (no path).
Example: https://chromium.googlesource.com
Example: https://chromium-review.googlesource.com
"""
return parts._replace(path='', query='', fragment='').geturl()
def _url_root_url(parts: urllib.parse.SplitResult) -> str:
"""Format URL with root path.
Example: https://chromium.googlesource.com/
Example: https://chromium-review.googlesource.com/
"""
return parts._replace(path='/', query='', fragment='').geturl()
def _url_review_host(parts: urllib.parse.SplitResult) -> str:
"""Format URL as Gerrit review host.
@@ -830,21 +848,3 @@ def _url_shortname(parts: urllib.parse.SplitResult) -> str:
if name.endswith('-review'):
name = name[:-len('-review')]
return name
def _url_host_url(parts: urllib.parse.SplitResult) -> str:
"""Format URL with host only (no path).
Example: https://chromium.googlesource.com
Example: https://chromium-review.googlesource.com
"""
return parts._replace(path='', query='', fragment='').geturl()
def _url_root_url(parts: urllib.parse.SplitResult) -> str:
"""Format URL with root path.
Example: https://chromium.googlesource.com/
Example: https://chromium-review.googlesource.com/
"""
return parts._replace(path='/', query='', fragment='').geturl()