mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Handle release when project is forked.
This commit is contained in:
@@ -123,6 +123,8 @@ class APP(object):
|
|||||||
from src.downloader.github import Github
|
from src.downloader.github import Github
|
||||||
|
|
||||||
tag, url = Github.patch_resource(url, assets_filter, config)
|
tag, url = Github.patch_resource(url, assets_filter, config)
|
||||||
|
if tag.startswith("tags/"):
|
||||||
|
tag = tag.split("/")[-1]
|
||||||
elif url.startswith("local://"):
|
elif url.startswith("local://"):
|
||||||
return tag, url.split("/")[-1]
|
return tag, url.split("/")[-1]
|
||||||
if not file_name:
|
if not file_name:
|
||||||
|
|||||||
@@ -57,10 +57,13 @@ class Github(Downloader):
|
|||||||
tag_position = 3
|
tag_position = 3
|
||||||
if len(path_segments) > tag_position and path_segments[3] == "latest-prerelease":
|
if len(path_segments) > tag_position and path_segments[3] == "latest-prerelease":
|
||||||
logger.info(f"Including pre-releases/beta for {github_repo_name} selection.")
|
logger.info(f"Including pre-releases/beta for {github_repo_name} selection.")
|
||||||
pre_ok = True
|
latest_tag = str(latest(f"{github_repo_owner}/{github_repo_name}", output_format="tag", pre_ok=True))
|
||||||
|
release_tag = f"tags/{latest_tag}"
|
||||||
else:
|
else:
|
||||||
pre_ok = False
|
release_tag = next(
|
||||||
release_tag = str(latest(f"{github_repo_owner}/{github_repo_name}", output_format="tag", pre_ok=pre_ok))
|
(f"tags/{path_segments[i + 1]}" for i, segment in enumerate(path_segments) if segment == "tag"),
|
||||||
|
"latest",
|
||||||
|
)
|
||||||
return github_repo_owner, github_repo_name, release_tag
|
return github_repo_owner, github_repo_name, release_tag
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -70,7 +73,7 @@ class Github(Downloader):
|
|||||||
release_tag: str,
|
release_tag: str,
|
||||||
asset_filter: str,
|
asset_filter: str,
|
||||||
config: RevancedConfig,
|
config: RevancedConfig,
|
||||||
) -> str:
|
) -> tuple[str, str]:
|
||||||
"""Get assets from given tag."""
|
"""Get assets from given tag."""
|
||||||
api_url = f"https://api.github.com/repos/{github_repo_owner}/{github_repo_name}/releases/{release_tag}"
|
api_url = f"https://api.github.com/repos/{github_repo_owner}/{github_repo_name}/releases/{release_tag}"
|
||||||
headers = {
|
headers = {
|
||||||
@@ -92,12 +95,11 @@ class Github(Downloader):
|
|||||||
assets_name = asset["name"]
|
assets_name = asset["name"]
|
||||||
if match := filter_pattern.search(assets_url):
|
if match := filter_pattern.search(assets_url):
|
||||||
logger.debug(f"Found {assets_name} to be downloaded from {assets_url}")
|
logger.debug(f"Found {assets_name} to be downloaded from {assets_url}")
|
||||||
return match.group()
|
return response.json()["tag_name"], match.group()
|
||||||
return ""
|
return "", ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def patch_resource(repo_url: str, assets_filter: str, config: RevancedConfig) -> tuple[str, str]:
|
def patch_resource(repo_url: str, assets_filter: str, config: RevancedConfig) -> tuple[str, str]:
|
||||||
"""Fetch patch resource from repo url."""
|
"""Fetch patch resource from repo url."""
|
||||||
repo_owner, repo_name, latest_tag = Github._extract_repo_owner_and_tag(repo_url)
|
repo_owner, repo_name, latest_tag = Github._extract_repo_owner_and_tag(repo_url)
|
||||||
tag = f"tags/{latest_tag}"
|
return Github._get_release_assets(repo_owner, repo_name, latest_tag, assets_filter, config)
|
||||||
return latest_tag, Github._get_release_assets(repo_owner, repo_name, tag, assets_filter, config)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user