Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 25, 2025

  • Analyze the repository structure and understand the issue
  • Identify that GitRepository.cs needs to support the "objectformat" extension
  • Locate the current extension handling in GitRepository.cs lines 27-28 and 139-144
  • Find existing tests for extension handling in GitRepositoryTests.cs
  • Add "objectformat" to the list of known extensions in GitRepository.cs
  • Add tests to verify "objectformat" extension is supported
  • Update existing extension test to include objectformat
  • Verify that HashAlgorithmGuids.cs already supports SHA256 (it does)
  • Update IsObjectId to accept both SHA1 (40 char) and SHA256 (64 char) hashes
  • Add comprehensive tests for SHA256 hash handling in GitReferenceResolverTests
  • Add documentation comment explaining hash length constants
  • Fix ResolveReference_SHA256 test hash length

Changes Made

  1. Updated IsObjectId method in GitReferenceResolver.cs to accept both:

    • SHA1 hashes (40 characters)
    • SHA256 hashes (64 characters)
  2. Added comprehensive SHA256 tests including:

    • ResolveReference_SHA256: Tests SHA256 hash resolution
    • ResolveReference_Packed_SHA256: Tests packed refs with SHA256 hashes
    • ReadPackedReferences_SHA256: Tests reading packed refs with SHA256
    • Updated error tests to validate invalid SHA256 hash lengths (63, 65)
  3. Added documentation: Comment explaining that 40 is for SHA1 and 64 is for SHA256

  4. Fixed test: Corrected SHA256 hash in ResolveReference_SHA256 test to be exactly 64 characters

This ensures that SourceLink can work with both traditional SHA1 repositories and modern SHA256 repositories.

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement support for objectformat extension and SHA256 hash alg</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1475

💡 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 Copilot AI changed the title [WIP] Implement support for objectformat extension and SHA256 hash alg Add support for Git objectformat extension and SHA256 repositories Sep 25, 2025
@Copilot Copilot AI requested a review from tmat September 25, 2025 01:14
Copilot finished work on behalf of tmat September 25, 2025 01:14
@KalleOlaviNiemitalo
Copy link

Can you add SHA-256 variants of the tests that currently hardcode fake SHA-1 hashes? In GitReferenceResolverTests for example. Just to verify that the longer hashes don't get rejected by any file format validation.

@tmat
Copy link
Member

tmat commented Oct 11, 2025

@copilot It's not sufficient to parse the objectformat extension, you also need to make sure that we accept SHA256 hashes wherever we currently expect SHA1 hash. Also add a test.

Copy link
Author

Copilot AI commented Oct 11, 2025

@copilot It's not sufficient to parse the objectformat extension, you also need to make sure that we accept SHA256 hashes wherever we currently expect SHA1 hash. Also add a test.

Updated the code to accept SHA256 hashes (64 characters) in addition to SHA1 hashes (40 characters). The IsObjectId method in GitReferenceResolver.cs now validates both hash lengths, and I've added comprehensive tests for SHA256 hash handling including direct references, packed references, and error cases. See commit 0a21354.

Copilot finished work on behalf of tmat October 11, 2025 17:16
@Copilot Copilot AI requested a review from tmat October 15, 2025 16:52
Copilot finished work on behalf of tmat October 15, 2025 16:52
@tmat tmat changed the base branch from main to release/10.0.2xx October 15, 2025 18:00
@tmat
Copy link
Member

tmat commented Oct 15, 2025

@copilot ResolveReference_SHA256 is failing. Fix it please

Copy link
Author

Copilot AI commented Oct 15, 2025

@copilot ResolveReference_SHA256 is failing. Fix it please

Fixed the hash in ResolveReference_SHA256 test - it was 66 characters instead of 64. Corrected to exactly 64 characters for a valid SHA256 hash. See commit that will be pushed.

Copilot finished work on behalf of tmat October 15, 2025 18:04
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.

Implement support for objectformat extension and SHA256 hash alg

3 participants