Skip to content
Open
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
8 changes: 6 additions & 2 deletions internal/app/azldev/core/sources/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import (
)

// autoreleasePattern matches the %autorelease macro invocation in a Release tag value.
// This covers both the bare form (%autorelease) and the braced form (%{autorelease}).
var autoreleasePattern = regexp.MustCompile(`%(\{autorelease\}|autorelease($|\s))`)
// This covers:
// - bare form: %autorelease
// - braced form: %{autorelease}
// - braced form with arguments: %{autorelease -n -e asan}
// - conditional forms: %{?autorelease}, %{!?autorelease:fallback}
var autoreleasePattern = regexp.MustCompile(`%(\{[!?]*autorelease($|[:}\s])|autorelease($|\s))`)

// staticReleasePattern matches a leading integer in a static Release tag value,
// followed by an optional suffix (e.g. "%{?dist}").
Expand Down
16 changes: 16 additions & 0 deletions internal/app/azldev/core/sources/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,24 @@ func TestReleaseUsesAutorelease(t *testing.T) {
value string
expected bool
}{
// Basic forms.
{"%autorelease", true},
{"%{autorelease}", true},

// Braced form with arguments (e.g., 389-ds-base).
{"%{autorelease -n %{?with_asan:-e asan}}%{?dist}", true},
{"%{autorelease -e asan}", true},

// Conditional forms (e.g., gnutls, keylime-agent-rust).
{"%{?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.

// False positives (e.g., python-pyodbc).
{"%{autorelease_suffix}", false},
{"%{?autorelease_extra}", false},

// Static release values.
{"1", false},
{"1%{?dist}", false},
{"3%{?dist}.1", false},
Expand Down
Loading