Skip to content

Commit feeb59a

Browse files
Tonisal-byteAntonio Salinas
andauthored
fix: handle additional %autorelease macro forms in Release tag detection (#91)
Co-authored-by: Antonio Salinas <asalinas@microsoft.com>
1 parent c4b8b03 commit feeb59a

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ 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+
// - braced form with arguments: %{autorelease -e asan}
24+
// - conditional form (no fallback): %{?autorelease}
25+
var autoreleasePattern = regexp.MustCompile(`%(\{[?]?autorelease($|[}\s])|autorelease($|\s))`)
2226

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

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,28 @@ 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+
// Conditional forms with a fallback value are NOT autorelease — the fallback
36+
// means we cannot conclusively determine that autorelease is being used.
37+
{"%{!?autorelease:1%{?dist}}", false},
38+
{"%{?autorelease:1%{?dist}}", false},
39+
40+
// False positives (e.g., python-pyodbc).
41+
{"%{autorelease_suffix}", false},
42+
{"%{?autorelease_extra}", false},
43+
44+
// Static release values.
2545
{"1", false},
2646
{"1%{?dist}", false},
2747
{"3%{?dist}.1", false},

0 commit comments

Comments
 (0)