Skip to content

feat: migration command #5506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Mar 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
973f628
chore: neutral configuration loader
ldez Feb 26, 2025
e24f69c
chore: copy v1 configuration structures
ldez Feb 26, 2025
519820a
chore: clean configuration v2
ldez Mar 1, 2025
450752d
chore: configuration v2 cloner
ldez Mar 1, 2025
1a74a2a
feat: migration command
ldez Mar 1, 2025
4ef8f4c
tests: configuration flles
ldez Mar 1, 2025
9bea57a
review: add comment on generated files
ldez Mar 5, 2025
101ac2a
review: add comment about v1 configuration files
ldez Mar 5, 2025
b7ca75f
review: rephrase
ldez Mar 5, 2025
e102282
review: log level
ldez Mar 5, 2025
ca11e3e
review: remove a switch
ldez Mar 5, 2025
d7d4986
fix: add a missing linter names migration case
ldez Mar 5, 2025
6e989eb
docs: improve v1 configuration files
ldez Mar 6, 2025
c95ec05
review: rename configuration packages
ldez Mar 6, 2025
8a3fbff
review
ldez Mar 6, 2025
064f43f
review: add log about run.timeout
ldez Mar 6, 2025
5ec43d0
review
ldez Mar 7, 2025
345e674
review
ldez Mar 7, 2025
1ab0066
review
ldez Mar 7, 2025
7df6432
review
ldez Mar 7, 2025
fe69114
feat: missing case
ldez Mar 7, 2025
a7e11f8
review
ldez Mar 8, 2025
fdf27fc
review
ldez Mar 8, 2025
e809f59
review
ldez Mar 8, 2025
7646196
chore: reduce log verbosity
ldez Mar 9, 2025
d66ff11
chore: rewrite the configuration loading
ldez Mar 9, 2025
0a90047
fix: toml multiline string
ldez Mar 9, 2025
8883832
chore: split test files by extensions
ldez Mar 10, 2025
d35e0d4
fix: exclude-use-default is true by default
ldez Mar 10, 2025
6cbdf61
review
ldez Mar 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review: log level
  • Loading branch information
ldez committed Mar 5, 2025
commit e1022822194279e1fdbd5ba1ced875851314ef3d
10 changes: 6 additions & 4 deletions pkg/commands/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *migrateCommand) execute(_ *cobra.Command, _ []string) error {
return err
}

c.cmd.Println("Migrating v1 configuration file:", srcPath)
c.log.Infof("Migrating v1 configuration file: %s", srcPath)

ext := filepath.Ext(srcPath)
if strings.TrimSpace(c.opts.format) != "" {
Expand All @@ -120,7 +120,7 @@ func (c *migrateCommand) execute(_ *cobra.Command, _ []string) error {
return fmt.Errorf("saving configuration file: %w", err)
}

c.cmd.Println("Migration done:", dstPath)
c.log.Infof("Migration done: %s", dstPath)

return nil
}
Expand All @@ -136,7 +136,7 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error {
os.Exit(exitcodes.NoConfigFileDetected)
}

c.cmd.Println("Validating v1 configuration file:", usedConfigFile)
c.log.Infof("Validating v1 configuration file: %s", usedConfigFile)

err := validateConfiguration("https://golangci-lint.run/jsonschema/golangci.v1.jsonschema.json", usedConfigFile)
if err != nil {
Expand All @@ -154,6 +154,8 @@ func (c *migrateCommand) preRunE(cmd *cobra.Command, _ []string) error {
}

func (c *migrateCommand) persistentPreRunE(_ *cobra.Command, args []string) error {
c.log.SetLevel(logutils.LogLevelInfo)

c.log.Infof("%s", c.buildInfo.String())

loader := config.NewBaseLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, c.opts.LoaderOptions, c.cfg, args)
Expand All @@ -170,7 +172,7 @@ func (c *migrateCommand) backupConfigurationFile(srcPath string) error {
filename := strings.TrimSuffix(filepath.Base(srcPath), filepath.Ext(srcPath)) + ".bck" + filepath.Ext(srcPath)
dstPath := filepath.Join(filepath.Dir(srcPath), filename)

c.cmd.Println("Saving the v1 configuration to:", dstPath)
c.log.Infof("Saving the v1 configuration to: %s", dstPath)

stat, err := os.Stat(srcPath)
if err != nil {
Expand Down