Skip to content

Commit 441adb7

Browse files
committed
fix: error message when trying to migrate a migrated config.
The check was done in the wrong place, so it was not triggered when the config was already migrated. Another error message was reported about jsonschema validation issues. Because a v2 config file does not validate against the v1 schema. That was misleading.
1 parent e7c4589 commit 441adb7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/commands/migrate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ func newMigrateCommand(log logutils.Log, info BuildInfo) *migrateCommand {
8181
}
8282

8383
func (c *migrateCommand) execute(_ *cobra.Command, _ []string) error {
84-
if c.cfg.Version != "" {
85-
return fmt.Errorf("configuration version is already set: %s", c.cfg.Version)
86-
}
87-
8884
srcPath := c.viper.ConfigFileUsed()
8985
if srcPath == "" {
9086
c.log.Warnf("No config file detected")
@@ -151,6 +147,10 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error {
151147
os.Exit(exitcodes.NoConfigFileDetected)
152148
}
153149

150+
if c.cfg.Version != "" {
151+
return fmt.Errorf("configuration version is already set: %s", c.cfg.Version)
152+
}
153+
154154
c.log.Infof("Validating v1 configuration file: %s", usedConfigFile)
155155

156156
err := validateConfiguration("https://golangci-lint.run/jsonschema/golangci.v1.jsonschema.json", usedConfigFile)

0 commit comments

Comments
 (0)