yaziPlugins/update: allow updating different default branches (#405625)
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
}:
|
||||
mkYaziPlugin {
|
||||
pname = "bypass.yazi";
|
||||
version = "0-unstable-2025-04-09";
|
||||
version = "25.3.2-unstable-2025-04-22";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Rolv-Apneseth";
|
||||
repo = "bypass.yazi";
|
||||
rev = "2ab6d84e8165985dd4d63ef0098e3a30feb3a41a";
|
||||
hash = "sha256-6LiBUvHmN8q/ao1+QhCg75ypuf1i6MyRQiU16Lb8pEs=";
|
||||
rev = "17e86529b2aa8ea7c08e117debf7c55044f9edb4";
|
||||
hash = "sha256-Q5g23sCGx9Ecm350ZiGKA1OaRieECWtF1xe22WzTtdY=";
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
}:
|
||||
mkYaziPlugin {
|
||||
pname = "mediainfo.yazi";
|
||||
version = "25.2.7-unstable-2025-04-05";
|
||||
version = "25.2.7-unstable-2025-04-17";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "boydaihungst";
|
||||
repo = "mediainfo.yazi";
|
||||
rev = "436cb5f04d6e5e86ddc0386527254d87b7751ec8";
|
||||
hash = "sha256-oFp8mJ62FsJX46mKQ7/o6qXPC9qx3+oSfqS0cKUZETI=";
|
||||
rev = "9629b1e85c3757c834ec83fb7d931982c55f4c3f";
|
||||
hash = "sha256-EDEIiZJy/RfXVaLNsKDeklH4qY2h+js2m0y6VSAjPkk=";
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -49,10 +49,25 @@ def get_github_headers() -> Dict[str, str]:
|
||||
return headers
|
||||
|
||||
|
||||
def get_default_branch(owner: str, repo: str, headers: Dict[str, str]) -> str:
|
||||
"""Get the default branch name for a GitHub repository"""
|
||||
api_url = f"https://api.github.com/repos/{owner}/{repo}"
|
||||
|
||||
try:
|
||||
response = requests.get(api_url, headers=headers)
|
||||
response.raise_for_status()
|
||||
repo_data = response.json()
|
||||
return repo_data["default_branch"]
|
||||
except requests.RequestException as e:
|
||||
print(f"Error fetching repository data: {e}")
|
||||
print("Falling back to 'main' as default branch")
|
||||
return "main"
|
||||
|
||||
def fetch_plugin_content(owner: str, repo: str, plugin_pname: str, headers: Dict[str, str]) -> str:
|
||||
"""Fetch the plugin's main.lua content from GitHub"""
|
||||
default_branch = get_default_branch(owner, repo, headers)
|
||||
plugin_path = f"{plugin_pname}/" if owner == "yazi-rs" else ""
|
||||
main_lua_url = f"https://raw.githubusercontent.com/{owner}/{repo}/main/{plugin_path}main.lua"
|
||||
main_lua_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{default_branch}/{plugin_path}main.lua"
|
||||
|
||||
try:
|
||||
response = requests.get(main_lua_url, headers=headers)
|
||||
@@ -81,12 +96,14 @@ def check_version_compatibility(plugin_content: str, plugin_name: str, yazi_vers
|
||||
|
||||
def get_latest_commit(owner: str, repo: str, plugin_pname: str, headers: Dict[str, str]) -> Tuple[str, str]:
|
||||
"""Get the latest commit hash and date for the plugin"""
|
||||
default_branch = get_default_branch(owner, repo, headers)
|
||||
|
||||
if owner == "yazi-rs":
|
||||
# For official plugins, get commit info for the specific plugin file
|
||||
api_url = f"https://api.github.com/repos/{owner}/{repo}/commits?path={plugin_pname}/main.lua&per_page=1"
|
||||
else:
|
||||
# For third-party plugins, get latest commit on main branch
|
||||
api_url = f"https://api.github.com/repos/{owner}/{repo}/commits/main"
|
||||
# For third-party plugins, get latest commit on default branch
|
||||
api_url = f"https://api.github.com/repos/{owner}/{repo}/commits/{default_branch}"
|
||||
|
||||
try:
|
||||
response = requests.get(api_url, headers=headers)
|
||||
|
||||
Reference in New Issue
Block a user