Skip to content

Fix version height computed as 0 when project path has non-canonical casing #1244

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
merged 4 commits into from
Aug 10, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 10, 2025

When a project's repo-relative path case doesn't match what git records (e.g., project reports path as a/b but git records it as A/b), the managed git implementation fails to walk the tree when searching for version.json files. This results in a version height of 0 instead of the correct value.

Root Cause

The issue was in ManagedVersionFile.GetVersion() at line 164 where GetTreeEntry() uses case-sensitive matching to find directory entries. When the path casing doesn't match git's records, the tree walk fails and no version.json file is found.

Solution

This PR implements case-insensitive fallback logic for the managed git implementation:

  1. Git Config Reading: Added ReadIgnoreCaseFromConfig() method to read core.ignorecase setting from git configuration files (both repository-specific and global)

  2. Case-Insensitive Tree Matching: Extended GitTreeStreamingReader.FindNode() with an optional ignoreCase parameter that performs ASCII case-insensitive comparison

  3. Fallback Logic: Modified GitRepository.GetTreeEntry() to attempt case-insensitive matching when core.ignorecase=true and the initial case-sensitive search fails

Example

// Before: This would fail if git recorded the path as "MyProject" but code used "myproject"
var versionOptions = context.VersionFile.GetVersion("myproject");  // Returns null

// After: With core.ignorecase=true, this now works correctly
var versionOptions = context.VersionFile.GetVersion("myproject");  // Returns version info

Testing

  • Added comprehensive unit tests covering case-sensitive, case-insensitive, and edge case scenarios
  • All existing tests continue to pass, confirming no regressions
  • The LibGit2 implementation already handles this correctly via libgit2's native case-insensitive support

Fixes #618.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • aka.ms
    • Triggering command: curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED (dns block)
  • dotnetbuilds.azureedge.net
    • Triggering command: curl --retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs REDACTED (dns block)
    • Triggering command: curl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits August 10, 2025 19:29
…mentation

Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Version height computed to be 0 when project is built with path with non-canonical casing Fix version height computed as 0 when project path has non-canonical casing Aug 10, 2025
@Copilot Copilot AI requested a review from AArnott August 10, 2025 19:35
Copilot finished work on behalf of AArnott August 10, 2025 19:35
@AArnott AArnott marked this pull request as ready for review August 10, 2025 19:53
@AArnott AArnott enabled auto-merge (squash) August 10, 2025 19:53
@AArnott AArnott added this to the v3.8 milestone Aug 10, 2025
@AArnott AArnott merged commit c273e6a into main Aug 10, 2025
12 checks passed
@AArnott AArnott deleted the copilot/fix-618 branch August 10, 2025 20:11
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.

Version height computed to be 0 when project is built with path with non-canonical casing
2 participants