Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of %prep macros #356

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions specfile/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ def parse(cls, section: Section) -> "Prep":
m.group("d"),
m.group("o"),
)
if delimiter == "" and option_string != "":
# delimiter can't be empty unless the match is just base macro with no options
buffer.append(line)
continue
prefix += line[: m.start("m")]
suffix = line[m.end("o") :] + suffix
klass = next(
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/test_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ def test_prep_parse():
"prep",
data=[
"%setup -q",
"# a comment",
"# list all patches",
"echo %patches",
"%patch0 -p1",
"%{!?skip_patch2:%patch2 -p2}",
"",
],
)
)
assert len(prep.macros) == 3
assert prep.macros[0].name == "%setup"
assert prep.macros[0].options.q
assert prep.macros[1].name == "%patch0"
Expand Down Expand Up @@ -147,7 +149,7 @@ def test_prep_get_raw_section_data():
PatchMacro.DEFAULTS,
),
" ",
preceding_lines=["# a comment"],
preceding_lines=["# list all patches", "echo %patches"],
),
PatchMacro(
PatchMacro.CANONICAL_NAME + "2",
Expand All @@ -166,7 +168,8 @@ def test_prep_get_raw_section_data():
)
assert prep.get_raw_section_data() == [
"%setup -q",
"# a comment",
"# list all patches",
"echo %patches",
"%patch0 -p1",
"%{!?skip_patch2:%patch2 -p2}",
"",
Expand Down
Loading