Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Jun 10, 2020

This PR initializes a non-empty config. Should a user desire an empty config, they can delete the contents of config.yml while leaving the file itself in place.

The default config contents are:

# What protocol to use when performing git operations. Supported values: ssh, https
git_protocol: https
# What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment.
editor:
# Aliases allow you to create nicknames for gh commands
aliases:
    co: pr checkout

Closes #1127
Closes #803

TODO

  • add a test

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the simplicity of this! I would just suggest that we move the trigger that creates this file to somewhere else. Perhaps NewBlankConfig could be initialized with yaml comments?

cfg, err := config.ParseDefaultConfig()
if errors.Is(err, os.ErrNotExist) {
cfg = config.NewBlankConfig()
cfg, err = config.InitDefaultConfig()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've moved away from Config() accessor resulting in side-effects such as kicking off authentication flow or making filesystem changes. It would be ideal if it could stay like that (i.e. not result in any mutations)

Instead, could we write the default config in case config.Write() was called, but config.yml was non-existent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is much better and i don't know why i thought i couldn't do that

@mislav
Copy link
Contributor

mislav commented Jun 11, 2020

Actually I will pre-emptively approve because it's good to ship-as is, but ideally accessing Config() should not result in side-effects. It's reasonable to address this as follow-up.

@vilmibm vilmibm merged commit 1ef6d4b into cli:trunk Jun 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

default aliases Documented config file

2 participants