Skip to content

Add git version check for overlay analysis enablement#3370

Merged
henrymercer merged 22 commits intomainfrom
copilot/update-overlay-git-version-check
Dec 18, 2025
Merged

Add git version check for overlay analysis enablement#3370
henrymercer merged 22 commits intomainfrom
copilot/update-overlay-git-version-check

Conversation

Copy link
Contributor

Copilot AI commented Dec 16, 2025

Overlay analysis depends on getFileOidsUnderPath, which uses git ls-files --format option 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:
    • Added GIT_MINIMUM_VERSION_FOR_OVERLAY constant ("2.38.0")
    • Added getGitVersionOrThrow() function that throws with detailed error messages
    • Added getGitVersion() function with caching and error logging
    • Added gitVersionAtLeast() function for semver comparison
    • Added logGitVersionTelemetry() function to log git version as telemetry diagnostic
    • Added resetCachedGitVersion() for testing support
  • src/config-utils.ts: Added git version check in getOverlayDatabaseMode() that falls back to non-overlay analysis with a warning if git is too old
  • src/diagnostics.ts: Added makeTelemetryDiagnostic() helper function for creating telemetry-only diagnostics
  • src/init-action.ts:
    • Added call to logGitVersionTelemetry() for git version telemetry
    • Refactored bundle-download-telemetry and zstd-availability diagnostics to use makeTelemetryDiagnostic()
  • Tests: Added tests for version parsing (including Windows-style versions like 2.40.0.windows.1), caching behavior, and overlay fallback scenarios

When git version is insufficient, users will see:

Cannot build an overlay database because the installed Git version is older than 2.38.0. Falling back to creating a normal full database instead.

Risk assessment

  • Low risk: Changes add a precondition check to existing overlay analysis feature. Falls back gracefully to full database creation.

Which use cases does this change impact?

Workflow types:

  • Advanced setup - Impacts users who have custom CodeQL workflows.
  • Managed - Impacts users with dynamic workflows (Default Setup, CCR, ...).

Products:

  • Code Scanning - The changes impact analyses when analysis-kinds: code-scanning.

Environments:

  • Dotcom - Impacts CodeQL workflows on github.com and/or GitHub Enterprise Cloud with Data Residency.
  • GHES - Impacts CodeQL workflows on GitHub Enterprise Server.

How did/will you validate this change?

  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.

How will you know if something goes wrong after this change is released?

  • Telemetry - I rely on existing telemetry or have made changes to the telemetry.
    • Dashboards - I will watch relevant dashboards for issues after the release.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.
Original prompt

Overlay analysis depends on getFileOidsUnderPath, which requires a git version of at least 2.38.0. Update the enablement check for overlay to ensure the git version is new enough


💡 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.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Should be of average difficulty to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants