Skip to content

Commit 0a67e41

Browse files
author
Antonio Salinas
committed
Upgraded regex to accept conditional autorelease
1 parent 344e4e9 commit 0a67e41

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

internal/app/azldev/core/sources/release.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ import (
1717
)
1818

1919
// autoreleasePattern matches the %autorelease macro invocation in a Release tag value.
20-
// This covers both the bare form (%autorelease) and the braced form (%{autorelease}).
21-
var autoreleasePattern = regexp.MustCompile(`%(\{autorelease\}|autorelease($|\s))`)
20+
// This covers:
21+
// - bare form: %autorelease
22+
// - braced form: %{autorelease}
23+
// - conditional form: %{?autorelease}
24+
var autoreleasePattern = regexp.MustCompile(`%(\{[?]?autorelease($|[:}\s])|autorelease($|\s))`)
2225

2326
// staticReleasePattern matches a leading integer in a static Release tag value,
2427
// followed by an optional suffix (e.g. "%{?dist}").

internal/app/azldev/core/sources/release_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,27 @@ func TestReleaseUsesAutorelease(t *testing.T) {
2020
value string
2121
expected bool
2222
}{
23+
// Basic forms.
2324
{"%autorelease", true},
2425
{"%{autorelease}", true},
26+
27+
// Braced form with arguments (e.g., 389-ds-base).
28+
{"%{autorelease -n %{?with_asan:-e asan}}%{?dist}", true},
29+
{"%{autorelease -e asan}", true},
30+
31+
// Conditional forms (e.g., gnutls, keylime-agent-rust).
32+
{"%{?autorelease}%{!?autorelease:1%{?dist}}", true},
33+
{"%{?autorelease}", true},
34+
35+
// Negated conditional alone is NOT autorelease — it provides a static fallback
36+
// for when the autorelease macro is not defined.
37+
{"%{!?autorelease:1%{?dist}}", false},
38+
39+
// False positives (e.g., python-pyodbc).
40+
{"%{autorelease_suffix}", false},
41+
{"%{?autorelease_extra}", false},
42+
43+
// Static release values.
2544
{"1", false},
2645
{"1%{?dist}", false},
2746
{"3%{?dist}.1", false},

0 commit comments

Comments
 (0)