Skip to content

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.

Copilot AI and others added 2 commits December 16, 2025 16:22
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>
@github-actions github-actions bot added the size/M Should be of average difficulty to review label Dec 16, 2025
Copilot AI changed the title [WIP] Update enablement check for overlay with git version requirement Add git version check for overlay analysis enablement Dec 16, 2025
Copilot AI requested a review from henrymercer December 16, 2025 16:32
@henrymercer henrymercer marked this pull request as ready for review December 16, 2025 16:56
@henrymercer henrymercer requested a review from a team as a code owner December 16, 2025 16:56
Copilot AI review requested due to automatic review settings December 16, 2025 16:56
Copy link
Contributor

Copilot AI left a 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

@henrymercer henrymercer removed their request for review December 16, 2025 16:56
@henrymercer
Copy link
Contributor

@copilot Please address the following feedback:

Error handling improvements

  • Cache the version of git, so we don't need to recompute it if we call gitVersionAtLeast multiple times
  • Refactor getGitVersion to getGitVersionOrThrow, and log the error message in gitVersionAtLeast, so we can debug using the original error message.

Telemetry

  • Add a helper function to diagnostics.ts that creates a telemetry diagnostic like the one we're creating for codeql-action/bundle-download-telemetry.
  • Modify getGitVersion to log a telemetry diagnostic with the git version number.

Copilot AI and others added 2 commits December 16, 2025 17:19
…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>
Copy link
Contributor Author

Copilot AI commented Dec 16, 2025

@copilot Please address the following feedback:

Error handling improvements

...

Addressed in commits c3dc529 and 393c074:

Error handling improvements:

  • Added caching for git version via cachedGitVersion module variable
  • Refactored to getGitVersionOrThrow() that throws with detailed error messages
  • getGitVersion() now logs errors with original message via getErrorMessage(e)
  • Added resetCachedGitVersion() for testing

Telemetry:

  • Added makeTelemetryDiagnostic() helper in diagnostics.ts
  • Added logGitVersionTelemetry() function that logs git version to telemetry
  • Called from init-action.ts after bundle download telemetry
  • Refactored existing bundle-download-telemetry and zstd-availability diagnostics to use the new helper

Copilot AI requested a review from henrymercer December 16, 2025 17:27
@henrymercer henrymercer removed their request for review December 16, 2025 17:30
@github-actions github-actions bot added size/L May be hard to review and removed size/M Should be of average difficulty to review labels Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L May be hard to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants