From 6d813d40aff91345b171323512b3ae641a168d45 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Feb 28 2023 08:25:23 +0000 Subject: Process source URLs with fragment in pre-push hook Some download services do not have the actual filename in the URL. Packagers work around that by adding a fragment to the URL. This is then ignored by any server, but tricks RPM into getting the correct filename. Example: Source0: https://crates.io/api/v1/crates/actix/0.13.0/download#/actix-0.13.0.crate The filename is obviously `actix-0.13.0.crate`, but rpkg without this patch will come up with `download`. Signed-off-by: Lubomír Sedlář --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 6a0e9eb..c650851 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -4464,7 +4464,9 @@ class Commands(object): # find out the format of the source file path. From URL use just the file name. # We want to keep hierarchy of the files if possible res = urllib.parse.urlparse(file_location) - if res.scheme and res.netloc: + if res.scheme and res.fragment: + source_files.append(os.path.basename(res.fragment)) + elif res.scheme and res.netloc: source_files.append(os.path.basename(res.path)) else: source_files.append(file_location)