Skip to content

Commit

Permalink
Tell Git that the bare repositories used in the tests are safe
Browse files Browse the repository at this point in the history
As of Git v2.38.0, there is an option to prevent Git from accessing bare
repositories unless asked for explicitly (via `--git-dir` or `GIT_DIR`):
`safe.bareRepository`.

The tests of `git sizer`, however, assume that Git will access a bare
repository when the current directory points inside that repository.
This only works if `safe.bareRepository` indicates that this is safe.

Let's just override whatever value the system or user-wide Git config
has for that config setting, to ensure that the tests can pass.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho authored and mhagger committed Dec 14, 2023
1 parent d605cdb commit e62a41c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions git_sizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ import (
"github.com/github/git-sizer/sizes"
)

func TestMain(m *testing.M) {
// Allow Git to access the bare repositories of these tests, even if
// the user configured `safe.bareRepository=explicit` globally.
os.Setenv("GIT_CONFIG_PARAMETERS", "'safe.bareRepository=all'")
os.Exit(m.Run())
}

func sizerExe(t *testing.T) string {
t.Helper()

Expand Down

0 comments on commit e62a41c

Please sign in to comment.