From ad763e44fb5b85d0092351cc0ed08751ec7d1767 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Wed, 15 Apr 2026 21:21:57 -0500 Subject: [PATCH] nixpkgs-plugin-update: handle special chars in tags Previously errored on special chars. Url encode refs. --- .../src/nixpkgs_plugin_update/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py b/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py index 1a54775d1dd2..c7988515bf7b 100644 --- a/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py +++ b/pkgs/development/python-modules/nixpkgs-plugin-update/nixpkgs-plugin-update/src/nixpkgs_plugin_update/__init__.py @@ -16,7 +16,6 @@ import sys import time import traceback import urllib.error -import urllib.parse import urllib.request import xml.etree.ElementTree as ET from dataclasses import asdict, dataclass @@ -26,7 +25,7 @@ from multiprocessing.dummy import Pool from pathlib import Path from tempfile import NamedTemporaryFile from typing import Any, Callable -from urllib.parse import urljoin, urlparse +from urllib.parse import urljoin, urlparse, urlsplit import git from packaging.version import InvalidVersion, parse as parse_version @@ -407,7 +406,7 @@ class RepoGitHub(Repo): response_url = req.geturl() if url != response_url: new_owner, new_name = ( - urllib.parse.urlsplit(response_url).path.strip("/").split("/")[:2] + urlsplit(response_url).path.strip("/").split("/")[:2] ) new_repo = RepoGitHub(owner=new_owner, repo=new_name, branch=self.branch) @@ -421,7 +420,15 @@ class RepoGitHub(Repo): return sha256 def prefetch_github(self, ref: str) -> str: - cmd = ["nix-prefetch-url", "--unpack", self.url(f"archive/{ref}.tar.gz")] + quoted_ref = quote(ref, safe="") + safe_name = re.sub(r"[^A-Za-z0-9._+-]", "-", f"{self.repo}-{ref}.tar.gz") + cmd = [ + "nix-prefetch-url", + "--unpack", + "--name", + safe_name, + self.url(f"archive/{quoted_ref}.tar.gz"), + ] log.debug("Running %s", cmd) data = subprocess.check_output(cmd) return data.strip().decode("utf-8")