cli / go-gh

A Go module for interacting with gh and the GitHub API from the command line.
https://pkg.go.dev/github.com/cli/go-gh/v2
MIT License
322 stars 45 forks source link

Config should load as unmodified #147

Closed williammartin closed 5 months ago

williammartin commented 5 months ago

Description

This PR relates to https://github.com/cli/cli/issues/8496

Since the config was moved to go-gh this bug has been lurking around. The idea behind IsModified is that the config file shouldn't be written if only hosts has changed, and vice versa. Unfortunately, if there is a hosts file then on load of the files, the config entry would be SetModified as a result of having the hosts being added as an entry.

The consequence of this is that any call to Write would attempt to write the config file, even if only hosts had changed.

This PR sets the top level Config as unmodified to avoid that.

Testing notes

This command should not write to the config file:

gh config set --host github.com boo bar

You can set the config file as immutable on Mac like so:

sudo chflags uchg ~/.config/gh/config.yml

and revert it with:

sudo chflags nouchg ~/.config/gh/config.yml