glab should keep configuration in .gitconfig and friends
Problem to solve
I have multiple gitlab accounts for both $client and my own private account. For my clients project I want to use a different token than I have for myself. Currently I either need to remember set variables via a wrapper around glab or something else. What would be cool if we can hook into the git config setup.
Eg. in a gitconfig you can do things like this:
[includeIf "gitdir:~/work/client/"]
path = ~/.config/git/client.config
This way I can set glab specific configs in the my client.config and I can use my own account in the specifics that I have myself:
[include]
path = ~/.config/git/private.config
[includeIf "gitdir:~/work/client/"]
path = ~/.config/git/client.config
This can be even tweaked further in a .git/config thing on a per repo basis. Pretty nifty I'd say
Proposal
My proposal is to deprecate the .config/glab-cli/config.yml in favor of git config.
Currently there is the config.yml file:
$ cat ~/.config/glab-cli/config.yml
# What protocol to use when performing git operations. Supported values: ssh, https
git_protocol: ssh
# What editor glab should run when creating issues, merge requests, etc. This is a global config that cannot be overridden by hostname.
editor:
# What browser glab should run when opening links. This is a global config that cannot be overridden by hostname.
browser:
# Set your desired markdown renderer style. Available options are [dark, light, notty] or set a custom style. Refer to https://github.com/charmbracelet/glamour#styles
glamour_style: dark
# Allow glab to automatically check for updates and notify you when there are new updates
check_update: false
# Whether or not to display hyperlink escapes when listing things like issues or MRs
display_hyperlinks: false
# configuration specific for gitlab instances
hosts:
gitlab.com:
# What protocol to use to access the api endpoint. Supported values: http, https
api_protocol: https
# Configure host for api endpoint, defaults to the host itself
api_host: gitlab.com
# Your GitLab access token. Get an access token at https://gitlab.com/-/profile/personal_access_tokens
token: TOKEN_HERE
git_protocol: ssh
user: myuser
This could move to in the gitconfig.
# global
glab.protocol https
glab.host gitlab
glab.token TOKEN_HERE
glab.user myuser
# per hostname
glab.<hostname>.protocol https
...
# In a remote in the repo's .git/config
remote.<remote>.glab-api-protocol https
remote.<remote>.glab-api-host gitlab.com
remote.<remote>.glab-token TOKEN_HERE
remote.<remote>.glab-user myuser
-
The git-protocol could be determined by the git config itself, what the fetch and push uri's are.
-
The editor can be determined what the
$EDITOR/$VISUALorcore.editoris, orglab.editor. Although I'm not certain why you'd want a different browser for glab other than your$EDITOR/$VISUALorcore.editorsettings. -
The browser..
glab.browser -
glamour_style:
glab.ui.glamour_style -
check-update: This may be one of the few things I'd keep here, but..
glab.check_update -
display_hyperlinks:
glab.ui.display_hyperlinks
Further details
The goal is to integrate glab more with git or.. to have a configuration that allows developers to use:
- Multiple accounts
- Change pieces of glab for one repo or a bunch of repo's
- Do it all in a way that feels familiar: git config
Links / references
I do something similar for my own tooling that doesn't require a seperate config and all my git stuf is in one place: .gitconfig and .config/git/<config>.config