fix: handle additional %autorelease macro forms in Release tag detection#91
fix: handle additional %autorelease macro forms in Release tag detection#91Tonisal-byte wants to merge 1 commit intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates %autorelease detection in spec Release tag parsing so rendering logic correctly treats additional valid rpmautospec macro forms as autorelease-based releases (including braced-with-args and conditional braced variants).
Changes:
- Expanded the
autoreleasePatternregex to match braced%{...}forms with optional conditional prefixes and arguments. - Added unit tests covering the newly supported macro patterns.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/app/azldev/core/sources/release.go | Expands the regex used by ReleaseUsesAutorelease() to recognize additional %autorelease macro forms. |
| internal/app/azldev/core/sources/release_test.go | Adds test cases for braced-with-args and conditional %autorelease forms. |
| // - braced form: %{autorelease} | ||
| // - braced form with arguments: %{autorelease -n -e asan} | ||
| // - conditional forms: %{?autorelease}, %{!?autorelease:fallback} | ||
| var autoreleasePattern = regexp.MustCompile(`%(\{[!?]*autorelease|autorelease($|\s))`) |
There was a problem hiding this comment.
autoreleasePattern is now too permissive: the \{[!?]*autorelease alternative doesn’t require a macro-name boundary (e.g., } / : / whitespace) after autorelease, so it will also match unrelated macros like %{autorelease_suffix} or %{?autorelease_extra}. Since ReleaseUsesAutorelease() controls whether static release bumps are skipped, these false-positives could suppress bumps unexpectedly. Consider tightening the regex to require a delimiter after autorelease (e.g., } / : / whitespace / end).
| var autoreleasePattern = regexp.MustCompile(`%(\{[!?]*autorelease|autorelease($|\s))`) | |
| // The braced form requires a delimiter after "autorelease" to avoid matching | |
| // unrelated macros such as %{autorelease_suffix} or %{?autorelease_extra}. | |
| var autoreleasePattern = regexp.MustCompile(`%(\{[!?]*autorelease($|[:}\s])|autorelease($|\s))`) |
There was a problem hiding this comment.
The copilot suggestion makes sense if for some reason there was a spec that wanted to use a macro that wasn't autorelease but started with autorelease. Making the change now!
| {"%{?autorelease}%{!?autorelease:1%{?dist}}", true}, | ||
| {"%{?autorelease}", true}, | ||
| {"%{!?autorelease:1%{?dist}}", true}, | ||
|
|
There was a problem hiding this comment.
Consider adding a negative regression case here to guard against false positives from the expanded regex (e.g., %{autorelease_suffix} or %{?autorelease_extra} should not be treated as %autorelease). This will help keep ReleaseUsesAutorelease() precise when the pattern is adjusted.
| // Similar-looking macros that must not match. | |
| {"%{autorelease_suffix}", false}, | |
| {"%{?autorelease_extra}", false}, |
053bf38 to
a0dc746
Compare
a0dc746 to
b4a3373
Compare
The
ReleaseUsesAutorelease()function failed to recognize several valid%autoreleasepatterns found in upstream specs:%{autorelease ...}(with arguments)%{?autorelease}(conditional)These conditional forms are used for backward compatibility—allowing specs to build both with rpmautospec (Fedora Koji) and without it (COPR, local mock).
Changes
autoreleasePatternregex to match braced forms with arguments and conditional?/!?prefixesResolves Rendering Packages