Implement fallback to global git config for user name retrieval#107
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a fallback in EnvironmentDetector so that when the local .git/config does not contain a [user] name, the global git config locations ($HOME/.gitconfig and $XDG_CONFIG_HOME/git/config) are consulted. Also suppresses CA5394 in sample projects.
Changes:
- Refactor
ReadGitConfigUserNameto first read local repo config, then fall back to$HOME/.gitconfig, then XDG-style$XDG_CONFIG_HOME/git/config, extracting the file-parsing logic into a helperReadUserNameFromFile. - Add an xUnit test exercising the global-config fallback path using a temporary
HOMEdirectory. - Suppress CA5394 (insecure randomness) in sample projects with an explanatory comment.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Xping.Sdk.Core/Services/Environment/Internals/EnvironmentDetector.cs | Implements the local → global → XDG fallback chain for git user name. |
| tests/Xping.Sdk.Core.Tests/Services/Environment/EnvironmentDetectorTests.cs | New test covering global-config fallback when local [user] is absent. |
| samples/Directory.Build.props | Suppress CA5394 in samples (random for flaky-test simulation). |
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance user name retrieval by checking the global git configuration if no local configuration is found. This change ensures a more robust method for obtaining user information in various environments.