@@ -70,33 +70,58 @@ func createSchemaURL(flags *pflag.FlagSet, buildInfo BuildInfo) (string, error)
70
70
return "" , fmt .Errorf ("parse version: %w" , err )
71
71
}
72
72
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
+ }
75
78
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
79
81
}
80
82
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
82
85
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
90
90
}
91
91
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
94
94
95
95
default :
96
96
return "" , errors .New ("version not found" )
97
97
}
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
+ }
98
123
99
- return schemaURL , nil
124
+ return commit , nil
100
125
}
101
126
102
127
func validateConfiguration (schemaPath , targetFile string ) error {
0 commit comments