Repository navigation
Accept SHA-256 commit ids in GetSourceLinkUrl - #1774
Merged
Merged
Conversation
Repositories using the sha256 object format produce a 64-character RevisionId, which the Git source link providers rejected as an invalid commit hash. Allow both 40 (SHA-1) and 64 (SHA-256) hex digits. Fixes dotnet#1772
|
LGTM. Don’t forget to accept the agreement |
tmat
approved these changes
Oct 12, 2026
tmat
enabled auto-merge (squash)
October 12, 2026 21:49
Member
|
@akashchamp this PR is good to merge, but you'll have to accept the CLA. |
agocke
reviewed
Oct 12, 2026
| var revisionId = SourceRoot.GetMetadata(Names.SourceRoot.RevisionId); | ||
| if (revisionId == null || revisionId.Length != 40 || !revisionId.All(IsHexDigit)) | ||
| // SHA-1 (40 hex digits) or SHA-256 (64 hex digits) object name. | ||
| if (revisionId == null || revisionId.Length is not (40 or 64) || !revisionId.All(IsHexDigit)) |
Member
There was a problem hiding this comment.
Should we just delete the length check entirely?
Contributor
Author
|
@dotnet-policy-service agree |
Member
|
/backport to release/11.0.1xx |
Contributor
|
Started backporting to |
tmat
pushed a commit
that referenced
this pull request
Oct 13, 2026
Repositories using the sha256 object format produce a 64-character RevisionId, which the Git source link providers rejected as an invalid commit hash. Allow both 40 (SHA-1) and 64 (SHA-256) hex digits. Fixes #1772 Co-authored-by: akashchamp <[email protected]>
tmat
pushed a commit
that referenced
this pull request
Nov 24, 2026
) * Accept SHA-256 commit ids in GetSourceLinkUrl (#1774) (#1775) Repositories using the sha256 object format produce a 64-character RevisionId, which the Git source link providers rejected as an invalid commit hash. Allow both 40 (SHA-1) and 64 (SHA-256) hex digits. Fixes #1772 Co-authored-by: akashchamp <[email protected]> * Merge pull request #1767 from dotnet/darc-release/11.0.1xx-c0d39cfa-e285-4d52-9528-869e3fab21cf [release/11.0.1xx] Source code updates from dotnet/dotnet * [release/11.0.1xx] Source code updates from dotnet/dotnet (#1780) * Backflow from https://github.com/dotnet/dotnet / 6fa58a2 build 337734 Diff: https://github.com/dotnet/dotnet/compare/3ca2426deb737052b09ad000a50f0327d77d544f..6fa58a2ef810f82b3197d69763cedfb34c88b9fd From: dotnet/dotnet@3ca2426 To: dotnet/dotnet@6fa58a2 [[ commit created by automation ]] * Update dependencies from build 337734 Updated Dependencies: Microsoft.DotNet.Arcade.Sdk (Version 11.0.0-beta.26480.113 -> 11.0.0-beta.26521.105) System.CommandLine (Version 3.0.0-rtm.26480.113 -> 3.0.0) System.IO.Hashing, System.Security.Cryptography.Xml, System.Text.Json (Version 11.0.0-rtm.26480.113 -> 11.0.0) [[ commit created by automation ]] * Use repository NuGet feeds in SDK integration tests Co-authored-by: Copilot <[email protected]> Copilot-Session: 50a9547c-92ce-4f2e-8ee3-664b5a00f3c0 * Update dependencies from build 338664 Updated Dependencies: Microsoft.DotNet.Arcade.Sdk (Version 11.0.0-beta.26521.105 -> 11.0.0-beta.26527.113) System.CommandLine (Version 3.0.0 -> 3.0.0) System.IO.Hashing, System.Security.Cryptography.Xml, System.Text.Json (Version 11.0.0 -> 11.0.0) [[ commit created by automation ]] --------- Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Alexander Köplinger <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: 50a9547c-92ce-4f2e-8ee3-664b5a00f3c0 * Reset files to release/11.0.2xx Reset patterns: - eng/Version.Details.xml - eng/Version.Details.props - eng/common/* - NuGet.config - global.json --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: akashchamp <[email protected]> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Alexander Köplinger <[email protected]> Co-authored-by: Copilot <[email protected]> Copilot-Session: 50a9547c-92ce-4f2e-8ee3-664b5a00f3c0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1772
GetSourceLinkUrlGitTaskonly accepted a 40-characterRevisionId, so a repository using thesha256object format failed with "is not a valid commit hash" in every Git provider (Gitea, GitHub, GitLab, ...), even thoughMicrosoft.Build.Tasks.Gitalready reads SHA-256 repositories. The check now accepts 40 (SHA-1) or 64 (SHA-256) hex digits.Tests: added a SHA-256 case to the common
GetSourceLinkUrlTestsand to the Gitea provider tests, plus 63/65-character and non-hex 64-character ids toRevisionId_Errors. The new success cases failed before the change. All*.UnitTestsprojects pass on net11.0 locally (Linux, so net472 not run).I also checked it end to end. I made a repo with
git init --object-format=sha256and a codeberg.org remote, then built a library that referencesMicrosoft.SourceLink.Giteafrom locally packed packages. With the packages packed frommain, the build fails with the error from the issue. With this change it succeeds and the generated sourcelink json is: