-
-
Notifications
You must be signed in to change notification settings - Fork 178
Automatically disable git engine for Dependabot environments #1284
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
Merged
+186
−4
Conversation
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
Collaborator
|
@copilot You can find additional context on the problem being fixed here at dependabot/dependabot-core#4660 |
- Add GetEffectiveGitEngine method to GitContext that checks DEPENDABOT env var - Update GetBuildVersion task to use the new logic - Update nbgv CLI tool (Program.cs) to use the new logic - Update CloudCommand to use the new logic - Add comprehensive tests for Dependabot detection - Update documentation to explain the automatic behavior Co-authored-by: AArnott <[email protected]>
- Move NBGV_GitEngine parsing into GitContext.GetEffectiveGitEngine - Simplify Program.cs GetEffectiveGitEngine to just call GitContext method - Update GetBuildVersion to respect MSBuild property over env vars - Enhance tests to cover all NBGV_GitEngine values (LibGit2, Managed, Disabled) - All 1105 tests passing Co-authored-by: AArnott <[email protected]>
- Clarify that unrecognized NBGV_GitEngine values are silently ignored - Document that this maintains backward compatibility - Explain valid values are LibGit2, Managed, and Disabled (case-sensitive) Co-authored-by: AArnott <[email protected]>
Copilot
AI
changed the title
[WIP] Enhance git versioning for Dependabot integration
Automatically disable git engine for Dependabot environments
Oct 15, 2025
AArnott
approved these changes
Oct 15, 2025
This was referenced Nov 5, 2025
This was referenced Dec 1, 2025
This was referenced Dec 9, 2025
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.
Summary
This PR enhances Nerdbank.GitVersioning to automatically disable the git engine when running under Dependabot, eliminating the need for manual configuration workarounds.
Problem
Dependabot operates on shallow clones, which causes Nerdbank.GitVersioning to fail since it requires access to git history. Previously, users needed to work around this limitation manually since Dependabot doesn't support custom environment variables. While a workaround existed (see dependabot/dependabot-core#4660), it required extra configuration that most users shouldn't need to manage.
Solution
This PR implements automatic detection of Dependabot environments:
DEPENDABOTenvironment variable is set to"true"(case-insensitive) and theNBGV_GitEngineenvironment variable is not set, Nerdbank.GitVersioning automatically behaves as ifNBGV_GitEngine=DisabledNBGV_GitEngineto override this automatic behavior if neededImplementation Details
Core Logic (
GitContext.cs):GetEffectiveGitEngine()public static method that centralizes engine selection logicDEPENDABOTenvironment variableNBGV_GitEnginevalues (LibGit2, Managed, Disabled) in one locationNBGV_GitEnginesettings (maintains user control)Integration Points:
GetBuildVersion.cs): MSBuildGitEngineproperty takes highest precedence, followed by environment variablesProgram.cs): Updated nbgv commands to use the centralized logicCloudCommand.cs): Updated cloud build integrationDocumentation (
shallow-cloning-agents.md):NBGV_GitEnginesetting overrides automatic detectionTesting
DEPENDABOT=trueNBGV_GitEngineis explicitly setBackward Compatibility
This change is fully backward compatible:
NBGV_GitEngineenvironment variable always takes precedenceGitEngineproperty continues to override environment variablesNBGV_GitEngineis not setNBGV_GitEnginevalues are silently ignored (maintains existing behavior)Example Usage
Fixes #[issue-number]
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.