-
Notifications
You must be signed in to change notification settings - Fork 428
Add git version check for overlay analysis enablement #3370
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
base: main
Are you sure you want to change the base?
Conversation
Overlay analysis depends on `getFileOidsUnderPath`, which uses `git ls-files --format` option that requires Git 2.38.0+. This change adds a check for the git version before enabling overlay analysis. Co-authored-by: henrymercer <14129055+henrymercer@users.noreply.github.com>
- Add test for Windows-style git version format - Add comment clarifying regex extracts major.minor.patch - Replace dynamic import with static import for semver Co-authored-by: henrymercer <14129055+henrymercer@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds Git version checking to ensure overlay analysis is only enabled when Git 2.38.0 or newer is available. Overlay analysis depends on the git ls-files --format option introduced in Git 2.38.0, and this change prevents runtime failures when an older Git version is installed.
Key changes:
- Added Git version detection and comparison utilities
- Integrated version check into overlay analysis enablement logic
- Falls back to full database analysis with a warning when Git is too old
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/git-utils.ts | Added version constants, parsing function, and comparison utilities for Git version checking |
| src/git-utils.test.ts | Added comprehensive test coverage for version parsing and comparison logic |
| src/config-utils.ts | Integrated Git version check into overlay database mode determination |
| src/config-utils.test.ts | Added test cases for overlay fallback scenarios with old/missing Git versions |
| lib/*.js | Generated JavaScript output from TypeScript compilation |
|
@copilot Please address the following feedback: Error handling improvements
Telemetry
|
…metry - Cache the git version to avoid recomputing on repeated calls - Refactor getGitVersion to getGitVersionOrThrow with detailed errors - Add getGitVersion that logs errors and handles caching - Add makeTelemetryDiagnostic helper to diagnostics.ts - Add logGitVersionTelemetry function to log git version telemetry - Call logGitVersionTelemetry in init-action.ts - Add resetCachedGitVersion for testing - Update tests to work with new function signatures and caching Co-authored-by: henrymercer <14129055+henrymercer@users.noreply.github.com>
Refactored bundle-download-telemetry and zstd-availability diagnostics in init-action.ts to use the new makeTelemetryDiagnostic helper function. Also added guard for empty languages array in logGitVersionTelemetry. Co-authored-by: henrymercer <14129055+henrymercer@users.noreply.github.com>
... Addressed in commits c3dc529 and 393c074: Error handling improvements:
Telemetry:
|
Overlay analysis depends on
getFileOidsUnderPath, which usesgit ls-files --formatoption introduced in Git 2.38.0. This adds a version check to ensure overlay analysis is only enabled when the git version is new enough.Changes
src/git-utils.ts:GIT_MINIMUM_VERSION_FOR_OVERLAYconstant ("2.38.0")getGitVersionOrThrow()function that throws with detailed error messagesgetGitVersion()function with caching and error logginggitVersionAtLeast()function for semver comparisonlogGitVersionTelemetry()function to log git version as telemetry diagnosticresetCachedGitVersion()for testing supportsrc/config-utils.ts: Added git version check ingetOverlayDatabaseMode()that falls back to non-overlay analysis with a warning if git is too oldsrc/diagnostics.ts: AddedmakeTelemetryDiagnostic()helper function for creating telemetry-only diagnosticssrc/init-action.ts:logGitVersionTelemetry()for git version telemetrybundle-download-telemetryandzstd-availabilitydiagnostics to usemakeTelemetryDiagnostic()2.40.0.windows.1), caching behavior, and overlay fallback scenariosWhen git version is insufficient, users will see:
Risk assessment
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, CCR, ...).Products:
analysis-kinds: code-scanning.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
.test.tsfiles).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist
Original prompt
💡 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.