Skip to content

Commit 63ff940

Browse files
author
Jakub Ruzicka
committed
Improve patches_ignore detection
patches_base was always added to .spec when it contained string 'patches_ignore' (like rdopkg does in changelog) due to an overly relaxed check. I used regex to make sure it only triggers for proper patches_ignore comment. No time was wasted on unit tests because all these hacks must be replaced with proper magic comment parser without silly expectations and million special cases. Fixes: #122 Change-Id: Ieadab8f7549da95b6408533f068471c02c9e39ec
1 parent 391dfb6 commit 63ff940

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

rdopkg/utils/specfile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,13 @@ def _create_new_patches_base(self, base):
305305
def set_patches_base(self, base):
306306
v, _ = self.get_patches_base()
307307

308-
if 'patches_ignore' in self.txt and (base is None or base == ''):
309-
base = self.get_tag('Version', expand_macros=True)
308+
if re.search("^#\s*patches_ignore\s*=\s*\S+", self.txt, flags=re.M):
309+
# This is a temporary hack as patches_ignore currently requires
310+
# explicit patches_base. This should be solved with a proper
311+
# magic comment parser and using Version in filtration logic
312+
# when no patches_base is defined.
313+
if not base:
314+
base = self.get_tag('Version', expand_macros=True)
310315
if base:
311316
regex = r'^#\s*patches_base*'
312317
if v is None and re.search(regex, self.txt, flags=re.M) is None:

0 commit comments

Comments
 (0)