44
55import requests
66
7+
78if sys .version_info >= (3 , 11 ):
89 import tomllib
910else :
@@ -16,23 +17,25 @@ def fetch_manifest(git_url, ref="main"):
1617 """Fetch MANIFEST.toml from git repository.
1718
1819 Args:
19- git_url: Git repository URL (GitHub only )
20+ git_url: Git repository URL (GitHub or GitLab )
2021 ref: Git ref (branch, tag, or commit)
2122
2223 Returns:
2324 dict: Parsed MANIFEST.toml content
2425
2526 Raises:
26- ValueError: If URL is not GitHub or manifest is invalid
27+ ValueError: If URL is not GitHub/GitLab or manifest is invalid
2728 requests.HTTPError: If manifest cannot be fetched
2829 """
29- if "github.com" not in git_url :
30- raise ValueError (f"Only GitHub URLs are supported: { git_url } " )
31-
32- # Convert to raw URL
33- raw_url = git_url .replace ("github.com" , "raw.githubusercontent.com" )
34- raw_url = raw_url .rstrip ("/" ).removesuffix (".git" )
35- manifest_url = f"{ raw_url } /{ ref } /MANIFEST.toml"
30+ git_url = git_url .rstrip ("/" ).removesuffix (".git" )
31+
32+ if "github.com" in git_url :
33+ raw_url = git_url .replace ("github.com" , "raw.githubusercontent.com" )
34+ manifest_url = f"{ raw_url } /{ ref } /MANIFEST.toml"
35+ elif "gitlab.com" in git_url :
36+ manifest_url = f"{ git_url } /-/raw/{ ref } /MANIFEST.toml"
37+ else :
38+ raise ValueError (f"Only GitHub and GitLab URLs are supported: { git_url } " )
3639
3740 response = requests .get (manifest_url , timeout = 10 )
3841 response .raise_for_status ()
0 commit comments