Skip to content

Commit 45265de

Browse files
author
Antonio Salinas
committed
Upgraded regex to accept conditional autorelease
1 parent 8640164 commit 45265de

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-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 -n -e asan}
24+
// - conditional forms: %{?autorelease}, %{!?autorelease:fallback}
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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,24 @@ 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+
{"%{!?autorelease:1%{?dist}}", true},
35+
36+
// False positives (e.g., python-pyodbc).
37+
{"%{autorelease_suffix}", false},
38+
{"%{?autorelease_extra}", false},
39+
40+
// Static release values.
2541
{"1", false},
2642
{"1%{?dist}", false},
2743
{"3%{?dist}.1", false},

0 commit comments

Comments
 (0)