Skip to content

fix: handle additional %autorelease macro forms in Release tag detection#91

Open
Tonisal-byte wants to merge 1 commit intomicrosoft:mainfrom
Tonisal-byte:asalinas/autorelease-parsing-fix
Open

fix: handle additional %autorelease macro forms in Release tag detection#91
Tonisal-byte wants to merge 1 commit intomicrosoft:mainfrom
Tonisal-byte:asalinas/autorelease-parsing-fix

Conversation

@Tonisal-byte
Copy link
Copy Markdown
Contributor

The ReleaseUsesAutorelease() function failed to recognize several valid %autorelease patterns found in upstream specs:

Pattern Example component
%{autorelease ...} (with arguments) 389-ds-base
%{?autorelease} (conditional) gnutls, keylime-agent-rust, libunistring, nettle, p11-kit

These conditional forms are used for backward compatibility—allowing specs to build both with rpmautospec (Fedora Koji) and without it (COPR, local mock).

Changes

  • Updated autoreleasePattern regex to match braced forms with arguments and conditional ?/!? prefixes
  • Added test cases covering the reported failures

Resolves Rendering Packages

  • 389-ds-base
  • gnutls
  • keylime-agent-rust
  • libunistring
  • nettle
  • p11-kit

Copilot AI review requested due to automatic review settings April 10, 2026 20:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 autoreleasePattern regex 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))`)
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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))`)

Copilot uses AI. Check for mistakes.
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.

@Tonisal-byte what's your take on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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},

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
// Similar-looking macros that must not match.
{"%{autorelease_suffix}", false},
{"%{?autorelease_extra}", false},

Copilot uses AI. Check for mistakes.
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.

Agreed on this for tests.

@Tonisal-byte Tonisal-byte force-pushed the asalinas/autorelease-parsing-fix branch from 053bf38 to a0dc746 Compare April 10, 2026 21:28
@Tonisal-byte Tonisal-byte force-pushed the asalinas/autorelease-parsing-fix branch from a0dc746 to b4a3373 Compare April 10, 2026 21:40
@reubeno reubeno requested a review from Copilot April 10, 2026 22:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

3 participants