Skip to content

Implement fallback to global git config for user name retrieval#107

Merged
xping-admin merged 1 commit into
mainfrom
fix/git-author-global-config-fallback
May 17, 2026
Merged

Implement fallback to global git config for user name retrieval#107
xping-admin merged 1 commit into
mainfrom
fix/git-author-global-config-fallback

Conversation

@xping-admin

Copy link
Copy Markdown
Collaborator

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ReadGitConfigUserName to 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 helper ReadUserNameFromFile.
  • Add an xUnit test exercising the global-config fallback path using a temporary HOME directory.
  • 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

codecov Bot commented May 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...vices/Environment/Internals/EnvironmentDetector.cs 43.75% 6 Missing and 3 partials ⚠️
Files with missing lines Coverage Δ
...vices/Environment/Internals/EnvironmentDetector.cs 50.37% <43.75%> (+0.90%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xping-admin
xping-admin merged commit 80d4c06 into main May 17, 2026
6 of 7 checks passed
@xping-admin
xping-admin deleted the fix/git-author-global-config-fallback branch May 17, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants