Open cakekindel opened 3 years ago
Hey @cakekindel, glad you're enjoying the tool & thanks for suggesting this feature.
This is definitely something that I'd like to support. Right now git-profile
works by setting the name & email config values, extending this to arbitrary config values shouldn't throw up any major problems.
I think there is some complexity around profile defaulting ie. if there's no profile explicitly activated in a repo, but the global name/email matches a profile, we say that that profile is in use. But if you had a config setting on that profile that isn't set up as a git global config, the UI would say the profile is in use, but you wouldn't have the config options set. I think that whole system of defaults (and the UI in general!) needs a significant overhaul anyway.
Awesome! My pie-in-the-sky UI would look something like this, mimicking the existing git ui wherever possible:
command | use | flags |
---|---|---|
git profile new <name> |
create a new git profile with name <name> with no profile-specific configuration values |
none |
git profile switch <name> |
switch to a git profile, changing the name, email, and any other configuration set in that profile | -c / --create - create profile if not exists |
git profile config get |
get all config values for a profile | -p <name> /--profile <name> - (required) profile to read config from |
git profile config get <key> |
get a config value for a profile | -p <name> /--profile <name> - (required) profile to read config from |
git profile config set <key>=<value> |
set a config value for a profile, whether active or not. If active, immediately applies the value to git-config |
-p <name> /--profile <name> - (required) profile to apply changes to |
following this, values like user.username
, user.email
, user.signingkey
would be set in the same way as the global gitconfig.
In terms of implementation, I can't think of a pretty version. Maybe a first blush would be creating a .gitconfig
for each profile and appending it to the user's global .gitconfig
, something like:
[user]
username = cakekindel
name = Orion Kindel
[commit]
gpgsign = true
[gpg]
program = gpg2
[init]
defaultBranch = main
# >>> DO NOT EDIT, AUTOGENERATED BY git-profile
# insert profile config
# <<<
Curious about your thoughts on this @dmfutcher!
Happy to help implement this by the way, as there's quite a bit of hidden complexity there. Converting the TUI git config syntax section.key=value
to [section]\n\tkey = value
, parsing .gitconfig
files, cross-platform FS interaction
Hey @cakekindel, that UI looks reasonable to me. I've been trying to think of a UI where the profile name is the first argument as it's the primary thing we want to act on/with (git profile <profile-name> <action> <...>
). Would let us avoid the slightly awkward -p
flags, but then it gets fiddly and frustratingly verbose if you want to act on the currently enabled profile.
There's another possible hurdle that I've thought of for this feature: right now the profiles are set locally per-repo. cd ..
out of the repo loses your profile & therefore settings. But I can imagine (no concrete example of this yet, I rarely fiddle with git config myself) there are global config settings which we'd like to apply from profiles? So that breaks the current model a bit. Can you tell git-profile
is a fairly proof-of-concept hack yet? 😅
Happy to redesign the whole overall model of how this works to enable a much more powerful tool. But haven't had any moments of inspiration about exactly how to do this yet! Wonder what your thoughts are here?
hi, great project here. would it be possible to use per-profile git configuration? that would solve the per-profile GPG signing issue along with many other potential future asks