@@ -70,33 +70,58 @@ func createSchemaURL(flags *pflag.FlagSet, buildInfo BuildInfo) (string, error)
7070 return "" , fmt .Errorf ("parse version: %w" , err )
7171 }
7272
73- schemaURL = fmt .Sprintf ("https://golangci-lint.run/jsonschema/golangci.v%d.%d.jsonschema.json" ,
74- version .Segments ()[0 ], version .Segments ()[1 ])
73+ if version .Core ().Equal (hcversion .Must (hcversion .NewVersion ("v0.0.0" ))) {
74+ commit , err := extractCommitHash (buildInfo )
75+ if err != nil {
76+ return "" , err
77+ }
7578
76- case buildInfo .Commit != "" && buildInfo .Commit != "?" :
77- if buildInfo .Commit == "unknown" {
78- return "" , errors .New ("unknown commit information" )
79+ return fmt .Sprintf ("https://raw.githubusercontent.com/golangci/golangci-lint/%s/jsonschema/golangci.next.jsonschema.json" ,
80+ commit ), nil
7981 }
8082
81- commit := buildInfo .Commit
83+ return fmt .Sprintf ("https://golangci-lint.run/jsonschema/golangci.v%d.%d.jsonschema.json" ,
84+ version .Segments ()[0 ], version .Segments ()[1 ]), nil
8285
83- if strings .HasPrefix (commit , "(" ) {
84- c , _ , ok := strings .Cut (strings .TrimPrefix (commit , "(" ), "," )
85- if ! ok {
86- return "" , errors .New ("commit information not found" )
87- }
88-
89- commit = c
86+ case buildInfo .Commit != "" && buildInfo .Commit != "?" :
87+ commit , err := extractCommitHash (buildInfo )
88+ if err != nil {
89+ return "" , err
9090 }
9191
92- schemaURL = fmt .Sprintf ("https://raw.githubusercontent.com/golangci/golangci-lint/%s/jsonschema/golangci.next.jsonschema.json" ,
93- commit )
92+ return fmt .Sprintf ("https://raw.githubusercontent.com/golangci/golangci-lint/%s/jsonschema/golangci.next.jsonschema.json" ,
93+ commit ), nil
9494
9595 default :
9696 return "" , errors .New ("version not found" )
9797 }
98+ }
99+
100+ func extractCommitHash (buildInfo BuildInfo ) (string , error ) {
101+ if buildInfo .Commit == "" || buildInfo .Commit == "?" {
102+ return "" , errors .New ("empty commit information" )
103+ }
104+
105+ if buildInfo .Commit == "unknown" {
106+ return "" , errors .New ("unknown commit information" )
107+ }
108+
109+ commit := buildInfo .Commit
110+
111+ if strings .HasPrefix (commit , "(" ) {
112+ c , _ , ok := strings .Cut (strings .TrimPrefix (commit , "(" ), "," )
113+ if ! ok {
114+ return "" , errors .New ("commit information not found" )
115+ }
116+
117+ commit = c
118+ }
119+
120+ if commit == "unknown" {
121+ return "" , errors .New ("unknown commit information" )
122+ }
98123
99- return schemaURL , nil
124+ return commit , nil
100125}
101126
102127func validateConfiguration (schemaPath , targetFile string ) error {
0 commit comments