Skip to content
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

Tests use user/system git config #989

Closed
rcoup opened this issue Mar 18, 2020 · 4 comments
Closed

Tests use user/system git config #989

rcoup opened this issue Mar 18, 2020 · 4 comments

Comments

@rcoup
Copy link
Contributor

rcoup commented Mar 18, 2020

eg:

  1. run git config --global diff.noprefix true
  2. pytest -v test/test_diff.py
  3. some tests fail

Presumably this is a symptom of the entire test run picking up the user/system git configuration, which seems bad from a reproducibility perspective? I couldn't see anything in the docs to tweak whether pygit2 picks up environment settings.

Setting GIT_CONFIG=/dev/null and GIT_CONFIG_NOSYSTEM=1 would sort it for cgit, but I don't think libgit2 picks up settings in the same way?

@jdavid jdavid added the tests label Mar 22, 2020
@jdavid
Copy link
Member

jdavid commented Mar 22, 2020

The documentation for git_repository_config says:

If a configuration file has not been set, the default config set for the repository will be returned, including global and system configurations (if they are available).

https://libgit2.org/libgit2/#HEAD/group/repository/git_repository_config

But didn't find how to set the config to a repository.

This is probably a question a libgit2 developer could answer faster than me, ping @ethomson @carlosmn

@jdavid jdavid added the libgit2 label Mar 22, 2020
@ethomson
Copy link
Member

We run into the same problem - the way we handle it in libgit2 is to set the various config search paths to dummy values to avoid them reading from the global paths.

libgit2: https://github.com/libgit2/libgit2/blob/master/tests/clar_libgit2.c#L565
LibGit2Sharp: https://github.com/libgit2/libgit2sharp/blob/9d2e900ca9da729eb7b20569965fc2f46d2ab2c7/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs#L93

@ethomson
Copy link
Member

This is something that we do before we ever init up a repository. I think that's probably the best approach, since opening a repository could hit those configs, I think. So if you can do it generally in the test harness, all the better.

@jdavid jdavid closed this as completed in eabfce1 Mar 24, 2020
@jdavid
Copy link
Member

jdavid commented Mar 24, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants