From 2a9507f1882bc6dbcf49f9dd39cbff451d41f1c9 Mon Sep 17 00:00:00 2001 From: Ondřej Nosek Date: Oct 15 2024 22:04:48 +0000 Subject: Fix regular expression for parsing Source lines When pushing changes to the dist-git repo, the `pre-push-check` didn't identify hidden files (.file) among 'SourceX|PatchX' definitions. The regular expression was taken from another part of the code and improved. Fixes: #721 JIRA: RHELCMP-13881 Signed-off-by: Ondřej Nosek --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index c3e1722..fd953b3 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -4575,8 +4575,9 @@ class Commands(object): source_files = [] # extract source files from the spectool's output for line in stdout.split('\n'): - file_location = re.sub(r'(?:Source|Patch)\d+\s*:\s*(\w+)', r'\1', line, re.IGNORECASE) - if file_location: + match = SpecFile.sourcefile_expression.match(line) + if match: + file_location = match.group('val') # 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) diff --git a/pyrpkg/spec.py b/pyrpkg/spec.py index 5400de3..28e3a27 100644 --- a/pyrpkg/spec.py +++ b/pyrpkg/spec.py @@ -15,7 +15,7 @@ from pyrpkg.errors import rpkgError class SpecFile(object): """Simple specfile parser that finds source file names""" sourcefile_expression = re.compile( - r'^((source[0-9]*|patch[0-9]*)\s*:\s*(?P.*))\s*$', + r'^(?:Source|Patch)\d*\s*:\s*(?P[^\s]+)\s*$', re.IGNORECASE) def __init__(self, spec, rpmdefines):