Skip to content

fix(tools): handle macro-based and autorelease Release fields in dist_bump - #118

Closed
mrbobbytables wants to merge 1 commit into
projectbluefin:mainfrom
mrbobbytables:fix-dist-bump-macro-release
Closed

mrbobbytables wants to merge 1 commit into
projectbluefin:mainfrom
mrbobbytables:fix-dist-bump-macro-release

Conversation

@mrbobbytables

Copy link
Copy Markdown
Contributor

Resolves #96.

Summary of Changes

  • Updated tools/dist_bump.py to support macro evaluation and expansion in spec_release():
    • Evaluates via rpmspec -q --srpm --qf %{RELEASE} if rpmspec is present in the environment
    • Expands %autorelease / %{autorelease} including base releases specified via -b
    • Evaluates local %global and %define spec macros (such as baserelease)
    • Evaluates/strips conditional macros (%{?...} tags)
    • Fails closed with BumpError if unhandled macros remain in the evaluated release string
  • Added unit tests in tests/test_dist_bump.py covering %autorelease, base flags, spec globals, conditionals, and invalid macros.

— hive: backend=copilot model=gemini-3.8-flash

🐝 Hive Agent: contributor | SHA: f8e61dc

…_bump

tools/dist_bump.py crashed or rejected specs when Release: used %autorelease
or macros such as %{baserelease} and conditional release macros like %{?gitdate:...}.

Support macro evaluation in spec_release() by:
- Querying rpmspec if available in the execution environment
- Expanding %autorelease / %{autorelease} (including -b <base>)
- Expanding local %global and %define macros referenced in Release:
- Stripping conditional macros (%{?...})
- Preserving strict BumpError failure if an unresolvable macro remains

Fixes projectbluefin#96

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two PRs solve the same Release: problem; I'm going with #100's shape and would rather not merge this one, for these reasons:

  • It expands macros with a hand-written parser (_strip_conditional_macros, %global/%define scraping, a five-pass substitution loop). The nested-brace walker treats %{ and %{? as the same opener and counts closers per character, so a value like %{?foo:%{bar}}%{?dist} is handled, but %{expand:...}, %[...] expressions and shell %(...) are not, and the failure mode is a wrong string rather than a refusal. rpmspec when present is the right instinct, but it isn't in the CI image for this step, so the fallback is what actually runs.
  • %autorelease → "1" is a guess: %autorelease on a spec that has been rebuilt is not 1, which is exactly the "two strings that do not mean what they appear to" the module's own docstring warns about. #100 skips the bump for that case and says so on stderr.
  • On today's main, tools/rebuild_plan.py expects spec_release() to signal "not comparable" (the test test_an_autorelease_recipe_falls_back_to_the_version asserts it); returning "1" for %autorelease breaks that.

Thanks for taking it on — the macro-in-Release: gap is real and #96 needed the push. Closing once #100 lands.


Generated by Claude Code

@hanthor

hanthor commented Sep 18, 2026

Copy link
Copy Markdown
Member

Closing per the review; #100 is landing with the simpler approach.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: tools/dist_bump.py crashes or behaves unpredictably on spec files with macro-based Release fields

2 participants