posh-git icon indicating copy to clipboard operation
posh-git copied to clipboard

Fix for failing tests when GPG Signing is enabled globally

Open DominikJaniec opened this issue 1 year ago • 0 comments

Have a global .gitconfig with:

[commit]
    gpgSign = true

Which makes Invoke-Pester to fail tests with:

  • One in Get-GitDirectory.Tests.ps1: Returns the correct dir when under a worktree
  • Three of Get-GitStatus.Tests.ps1 - all under: Context Branch progress suffix
  • A few from TabExpansion.Tests.ps1 - in contexts as:
    • Git Config Alias TabExpansion Tests
    • PowerShell Alias TabExpansion Tests
    • PowerShell Special Chars Tests

Those tests will fail, as they could not make commits. Moreover, some tests were being "polluting" global configuration with some test aliases, which were not removed after theirs execution.

Thus, your .gitconfig file became something like:

[commit]
    gpgSign = true
[alias]
	test-944577f4-7f84-4473-931d-93b95d9a65fd = config
	co = checkout

This PR should fix that, and tests should not be broken due to GPG configuration, and no foreign aliases should stay.

DominikJaniec avatar Feb 26 '23 17:02 DominikJaniec