[AddonManager] Fix construct_git_url return urls with '.git'. (#19242)

* [AddonManager] Fix construct_git_url return urls with '.git'.
This commit is contained in:
Tim
2025-01-26 20:45:14 +08:00
committed by GitHub
parent 87ed2bb6dc
commit 0db1a2e034

View File

@@ -198,19 +198,20 @@ def construct_git_url(repo, filename):
"""Returns a direct download link to a file in an online Git repo"""
parsed_url = urlparse(repo.url)
repo_url = repo.url[:-4] if repo.url.endswith(".git") else repo.url
if parsed_url.netloc == "github.com":
return f"{repo.url}/raw/{repo.branch}/{filename}"
return f"{repo_url}/raw/{repo.branch}/{filename}"
if parsed_url.netloc in ["gitlab.com", "framagit.org", "salsa.debian.org"]:
return f"{repo.url}/-/raw/{repo.branch}/{filename}"
return f"{repo_url}/-/raw/{repo.branch}/{filename}"
if parsed_url.netloc in ["codeberg.org"]:
return f"{repo.url}/raw/branch/{repo.branch}/{filename}"
return f"{repo_url}/raw/branch/{repo.branch}/{filename}"
fci.Console.PrintLog(
"Debug: addonmanager_utilities.construct_git_url: Unknown git host:"
+ parsed_url.netloc
+ f" for file {filename}\n"
)
# Assume it's some kind of local GitLab instance...
return f"{repo.url}/-/raw/{repo.branch}/{filename}"
return f"{repo_url}/-/raw/{repo.branch}/{filename}"
def get_readme_url(repo):