yaziPlugins/update: allow updating different default branches (#405625)

authored by Austin Horstman and committed by GitHub a5ca66c5 78616cf0

+26 -9
+3 -3
pkgs/by-name/ya/yazi/plugins/bypass/default.nix
··· 5 5 }: 6 6 mkYaziPlugin { 7 7 pname = "bypass.yazi"; 8 - version = "0-unstable-2025-04-09"; 8 + version = "25.3.2-unstable-2025-04-22"; 9 9 10 10 src = fetchFromGitHub { 11 11 owner = "Rolv-Apneseth"; 12 12 repo = "bypass.yazi"; 13 - rev = "2ab6d84e8165985dd4d63ef0098e3a30feb3a41a"; 14 - hash = "sha256-6LiBUvHmN8q/ao1+QhCg75ypuf1i6MyRQiU16Lb8pEs="; 13 + rev = "17e86529b2aa8ea7c08e117debf7c55044f9edb4"; 14 + hash = "sha256-Q5g23sCGx9Ecm350ZiGKA1OaRieECWtF1xe22WzTtdY="; 15 15 }; 16 16 17 17 meta = {
+3 -3
pkgs/by-name/ya/yazi/plugins/mediainfo/default.nix
··· 5 5 }: 6 6 mkYaziPlugin { 7 7 pname = "mediainfo.yazi"; 8 - version = "25.2.7-unstable-2025-04-05"; 8 + version = "25.2.7-unstable-2025-04-17"; 9 9 10 10 src = fetchFromGitHub { 11 11 owner = "boydaihungst"; 12 12 repo = "mediainfo.yazi"; 13 - rev = "436cb5f04d6e5e86ddc0386527254d87b7751ec8"; 14 - hash = "sha256-oFp8mJ62FsJX46mKQ7/o6qXPC9qx3+oSfqS0cKUZETI="; 13 + rev = "9629b1e85c3757c834ec83fb7d931982c55f4c3f"; 14 + hash = "sha256-EDEIiZJy/RfXVaLNsKDeklH4qY2h+js2m0y6VSAjPkk="; 15 15 }; 16 16 17 17 meta = {
+20 -3
pkgs/by-name/ya/yazi/plugins/update.py
··· 49 49 return headers 50 50 51 51 52 + def get_default_branch(owner: str, repo: str, headers: Dict[str, str]) -> str: 53 + """Get the default branch name for a GitHub repository""" 54 + api_url = f"https://api.github.com/repos/{owner}/{repo}" 55 + 56 + try: 57 + response = requests.get(api_url, headers=headers) 58 + response.raise_for_status() 59 + repo_data = response.json() 60 + return repo_data["default_branch"] 61 + except requests.RequestException as e: 62 + print(f"Error fetching repository data: {e}") 63 + print("Falling back to 'main' as default branch") 64 + return "main" 65 + 52 66 def fetch_plugin_content(owner: str, repo: str, plugin_pname: str, headers: Dict[str, str]) -> str: 53 67 """Fetch the plugin's main.lua content from GitHub""" 68 + default_branch = get_default_branch(owner, repo, headers) 54 69 plugin_path = f"{plugin_pname}/" if owner == "yazi-rs" else "" 55 - main_lua_url = f"https://raw.githubusercontent.com/{owner}/{repo}/main/{plugin_path}main.lua" 70 + main_lua_url = f"https://raw.githubusercontent.com/{owner}/{repo}/{default_branch}/{plugin_path}main.lua" 56 71 57 72 try: 58 73 response = requests.get(main_lua_url, headers=headers) ··· 81 96 82 97 def get_latest_commit(owner: str, repo: str, plugin_pname: str, headers: Dict[str, str]) -> Tuple[str, str]: 83 98 """Get the latest commit hash and date for the plugin""" 99 + default_branch = get_default_branch(owner, repo, headers) 100 + 84 101 if owner == "yazi-rs": 85 102 # For official plugins, get commit info for the specific plugin file 86 103 api_url = f"https://api.github.com/repos/{owner}/{repo}/commits?path={plugin_pname}/main.lua&per_page=1" 87 104 else: 88 - # For third-party plugins, get latest commit on main branch 89 - api_url = f"https://api.github.com/repos/{owner}/{repo}/commits/main" 105 + # For third-party plugins, get latest commit on default branch 106 + api_url = f"https://api.github.com/repos/{owner}/{repo}/commits/{default_branch}" 90 107 91 108 try: 92 109 response = requests.get(api_url, headers=headers)