Skip to content

Commit 01ce160

Browse files
refactor: rename version to min-version to avoid confusions
1 parent f9c5b86 commit 01ce160

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ To lint a message, you can use any one of the following
147147
## Default Config
148148

149149
```yaml
150-
version: v0.9.0
150+
min-version: v0.9.0
151151
formatter: default
152152
rules:
153153
- header-min-length

config/config.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ func Parse(confPath string) (*lint.Config, error) {
2626
}
2727

2828
conf := &lint.Config{
29-
MinVersion: internal.Version(),
30-
Formatter: (&formatter.DefaultFormatter{}).Name(),
29+
Formatter: (&formatter.DefaultFormatter{}).Name(),
3130
Severity: lint.SeverityConfig{
3231
Default: lint.SeverityError,
3332
},
@@ -38,6 +37,17 @@ func Parse(confPath string) (*lint.Config, error) {
3837
return nil, fmt.Errorf("config file error: %w", err)
3938
}
4039

40+
// Backward compatibility: accept old "version" key
41+
if conf.MinVersion == "" && conf.DeprecatedVersion != "" {
42+
conf.MinVersion = conf.DeprecatedVersion
43+
}
44+
conf.DeprecatedVersion = ""
45+
46+
// Default to current version if neither key was provided
47+
if conf.MinVersion == "" {
48+
conf.MinVersion = internal.Version()
49+
}
50+
4151
if conf.Formatter == "" {
4252
return nil, errors.New("config error: formatter is empty")
4353
}

lint/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ type SeverityConfig struct {
1616
type Config struct {
1717
// MinVersion is the minimum version of commitlint required
1818
// should be in semver format
19-
MinVersion string `yaml:"version"`
19+
MinVersion string `yaml:"min-version"`
20+
21+
// DeprecatedVersion is the old "version" key, kept for backward compatibility.
22+
// Use MinVersion ("min-version") in new config files.
23+
DeprecatedVersion string `yaml:"version,omitempty"`
2024

2125
// Formatter of the lint result
2226
Formatter string `yaml:"formatter"`

0 commit comments

Comments
 (0)