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

[git] Force an empty git config upon git command executions within a repository #844

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eskultety
Copy link
Member

I recently adopted some new global git configuration which happened to break some of our unit tests. While the tests in question definitely deserve changes not to be so tightly coupled to an exact git output, we should also not let git pick up user configuration automatically if we want to keep consuming its output and process it further in our logic.

Maintainers will complete the following section

  • Commit messages are descriptive enough
  • Code coverage from testing does not decrease and new code is covered
  • Docs updated (if applicable)
  • Docs links in the code are still valid (if docs were updated)

Note: if the contribution is external (not from an organization member), the CI
pipeline will not run automatically. After verifying that the CI is safe to run:

After having adopted some new global git configuration options I
started seeing some failures in unit tests dealing with git operations.
While the tests in question definitely deserve attention on their
approach, letting our git actions consume the local ~/.gitconfig
configuration file by default smells with non-determinism.

This patch introduces a new wrapping helper class that forces a null
config upon all git actions within a repository context. This is
achieved via usage of environment variables for this purpose (there
isn't a CLI option to do this). The change is sadly introduced as
a conditional behaviour depending on particular version of git, because
the new environment variables [1] were introduced in git 2.32.0 [2]
(released in 2021) and while most supported platforms
have already gone past the version, Debian 11 LTS is stuck at 2.30.

[1] https://www.kernel.org/pub/software/scm/git/docs/git.html
[2] https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.32.0.adoc

Signed-off-by: Erik Skultety <[email protected]>
Adopt the new wrapping class introduced in previous commit.

Signed-off-by: Erik Skultety <[email protected]>
@eskultety
Copy link
Member Author

If this approach is agreed upon then some of the existing scm.py functions could be nicely tucked under the new helper wrapping class as well.

@eskultety
Copy link
Member Author

Aand of course CI would require git config changes, sigh...

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

Successfully merging this pull request may close these issues.

1 participant