Skip to content

Conversation

@sandr01d
Copy link
Collaborator

Check list

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have added unit tests for my code
  • I have made corresponding changes to the documentation

Description

When creating commits in tests, it's best to pass the --no-gpg-sign flag. I have commit.gpgsign set to true in my git config. Without --no-gpg-sign, git wants me to enter a passphrase when running the tests, which is a bit annoying.

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Test
  • Documentation change

Test environment

  • Shell
    • bash
    • zsh
    • fish
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

@sandr01d sandr01d self-assigned this Dec 18, 2025
@sandr01d sandr01d changed the title Test: ensure commits created in tests are not gpg signed test: do not sign commits in tests Dec 18, 2025
@cjappl
Copy link
Collaborator

cjappl commented Dec 18, 2025

Is there a way to be able to pass "ignore the gitconfig" to these git commands? I think ideally all these tests would be completely independent of local gitconfig. It would be unexpected to have flakiness from that.

Copy link
Collaborator

@carlfriedrich carlfriedrich left a comment

Choose a reason for hiding this comment

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

I would also vote for trying to find a way to completely ignore the user's .gitconfig. As far as I can see, there is no option for git to do so, though.

Maybe we can set the HOME env variable for a test to a temp directory? This way, the user's config shouldn't be picked up at first. Not sure if this might have side effects, though.

@cjappl
Copy link
Collaborator

cjappl commented Dec 20, 2025

Possibly relevant?

https://superuser.com/questions/53030/run-git-commands-without-default-gitconfig

May be removed though, someone does recommend doing something like HOME= git ..., which does seem a little sketchy. Maybe worth a try but I'd be worried too

@carlfriedrich
Copy link
Collaborator

@cjappl Good find, and good idea setting HOME for the git call only. IMO that should be safe.

@sandr01d
Copy link
Collaborator Author

I've found another option, which I'd prefer. When GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM is set to /dev/null, git will ignore the global config file. You can find more details here.

@sandr01d sandr01d changed the title test: do not sign commits in tests test: ignore global config in tests Dec 21, 2025
@carlfriedrich
Copy link
Collaborator

@sandr01d Ah, great find. That makes sense. Approved!

@sandr01d sandr01d merged commit 024389f into wfxr:main Dec 21, 2025
3 checks passed
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.

3 participants