@@ -48,7 +48,7 @@ func TestNew(t *testing.T) {
4848 }
4949 })
5050
51- t .Run ("VCS metadata resolution" , func (t * testing.T ) {
51+ t .Run ("VCS metadata resolution with tagged release " , func (t * testing.T ) {
5252 v := & Version {KubeBuilderVersion : "v1.0.0" }
5353 settings := []debug.BuildSetting {
5454 {Key : "vcs.revision" , Value : "abcdef123" },
@@ -60,8 +60,9 @@ func TestNew(t *testing.T) {
6060 if ! strings .HasSuffix (v .GitCommit , "-dirty" ) {
6161 t .Errorf ("expected commit to be dirty, got %s" , v .GitCommit )
6262 }
63- if ! strings .Contains (v .KubeBuilderVersion , "-dirty" ) {
64- t .Errorf ("expected version to be dirty, got %s" , v .KubeBuilderVersion )
63+ // For tagged releases, we ignore dirty flag to support GoReleaser builds
64+ if v .KubeBuilderVersion != "v1.0.0" {
65+ t .Errorf ("expected version to remain v1.0.0, got %s" , v .KubeBuilderVersion )
6566 }
6667 })
6768
@@ -148,9 +149,32 @@ func TestApplyVCSMetadata(t *testing.T) {
148149 {Key : "vcs.time" , Value : "2025-12-29T19:30:00Z" },
149150 },
150151 expectCommit : "abcdef123-dirty" ,
151- expectVersion : "(devel)-dirty " ,
152+ expectVersion : "(devel)" ,
152153 expectDate : "2025-12-29T19:30:00Z" ,
153154 },
155+ {
156+ name : "Dirty tagged release (GoReleaser scenario)" ,
157+ initialVersion : "v4.5.3-rc.1" ,
158+ settings : []debug.BuildSetting {
159+ {Key : "vcs.revision" , Value : "abcdef123" },
160+ {Key : "vcs.modified" , Value : "true" },
161+ {Key : "vcs.time" , Value : "2025-12-30T10:00:00Z" },
162+ },
163+ expectCommit : "abcdef123-dirty" ,
164+ expectVersion : "v4.5.3-rc.1" , // Stays clean for tagged releases
165+ expectDate : "2025-12-30T10:00:00Z" ,
166+ },
167+ {
168+ name : "Dirty pseudo-version" ,
169+ initialVersion : "v1.2.4-0.20191109021931-daa7c04131f5" ,
170+ settings : []debug.BuildSetting {
171+ {Key : "vcs.revision" , Value : "abcdef123" },
172+ {Key : "vcs.modified" , Value : "true" },
173+ },
174+ expectCommit : "abcdef123-dirty" ,
175+ expectVersion : "(devel)" , // Pseudo-versions become (devel) when dirty
176+ expectDate : "" ,
177+ },
154178 }
155179
156180 for _ , tt := range tests {
0 commit comments