-
Notifications
You must be signed in to change notification settings - Fork 896
chore: prevent commit signing in tests #13222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Danny Kopping <danny@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting find! How about we set GIT_CONFIG_GLOBAL=/dev/null
(and GIT_CONFIG_SYSTEM=/dev/null
?) instead? This seems like it would be a more robust approach vs handling any special cases in user configurations?
I believe that it's not using the global config at all, but rather the one from my home dir which it doesn't seem possible to override. |
That's what global is for, to avoid using your home dir config. The system variant is for |
Oh interesting! I didn't see $ git config -l | grep alias.commit
alias.commit=commit -s
$ GIT_CONFIG_GLOBAL=/dev/null git config -l | grep alias.commit
$ |
Signed-off-by: Danny Kopping <danny@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, interesting. It is described in the man page, though:
GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM Take the configuration from the given files instead from global or system-level configuration files. If GIT_CONFIG_SYSTEM is set, the system config file defined at build time (usually /etc/gitconfig) will not be read. Likewise, if GIT_CONFIG_GLOBAL is set, neither $HOME/.gitconfig nor $XDG_CONFIG_HOME/git/config will be read. Can be set to /dev/null to skip reading configuration files of the respective level.
In my workspace, my git config contains this alias:
$ git config -l | grep alias.commit alias.commit=commit -s
When
TestDotfiles
is called, it runsgit commit
which tries to sign the commits and causes my tests to hang and fail. We need to prevent this behaviour.I tried using
GIT_CONFIG_NOSYSTEM
, but that doesn't prevent the use of the git config in my home directory.(source)
This feels like the cleanest approach to me; an alternative would be to override the
HOME
env var, but that could have other side-effects.Edit: @mafredri suggesting using GIT_CONFIG_GLOBAL=/dev/null
and
GIT_CONFIG_SYSTEM=/dev/null` which solves the problem more elegantly than my original solution.