File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,14 @@ func indent(text, indent string) string {
5151}
5252
5353func FindSemVerInfo (version string ) (string , error ) {
54- v := regexp .MustCompile (semVerRegex ).FindString (version )
54+ if version == "" {
55+ return "" , fmt .Errorf ("version cannot be empty" )
56+ }
57+ processedVersion := strings .TrimSpace (version )
58+ if ! strings .HasPrefix (processedVersion , "v" ) {
59+ processedVersion = fmt .Sprintf ("v%s" , processedVersion )
60+ }
61+ v := regexp .MustCompile (semVerRegex ).FindString (processedVersion )
5562
5663 if v == "" {
5764 return "" , fmt .Errorf ("unable to find semver info in %s" , version )
Original file line number Diff line number Diff line change @@ -82,10 +82,10 @@ func TestFindSemVerInfo(t *testing.T) {
8282 wantErr : false ,
8383 },
8484 {
85- name : "semver must start with v" ,
85+ name : "semver not start with v" ,
8686 version : "1.2.3" ,
87- want : "" ,
88- wantErr : true ,
87+ want : "v1.2.3 " ,
88+ wantErr : false ,
8989 },
9090 {
9191 name : "helm version info with WARNING message" ,
You can’t perform that action at this time.
0 commit comments