planetscale/cli

`branch switch` can write config files that are not used by default config

nickvanw opened this issue · 1 comments

When you run pscale branch switch ... it defaults to looking for a file in $CWD/.pscale: https://github.com/planetscale/cli/blob/main/internal/cmd/org/switch.go#L109-L129. If there is a file there already, it will write out the config.

However, when we're reading the config in when we run a new command, we'll currently only look at $CWD/.pscale if we're in a Git repository: https://github.com/planetscale/cli/blob/main/internal/cmd/root.go#L240

Other commands (such as pscale org switch) will similarly look at the $CWD/.pscale file first, write out a configuration, and then not be read.

The pscale switch commands should probably have the same logic as the configuration, otherwise you can get into a situation where you write a config file out that is not used.

h/t @FancyFane for reporting.

This was fixed by: #743