Skip to content

Preserve Git ownership metadata in source tarballs - #10917

Merged
mthalman merged 2 commits into
dotnet:mainfrom
mthalman:mthalman-source-tarball-git-ownership
Nov 11, 2026
Merged

mthalman merged 2 commits into
dotnet:mainfrom
mthalman:mthalman-source-tarball-git-ownership

Conversation

@mthalman

@mthalman mthalman commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Problem

Release signatures do not verify against GitHub-generated source tarballs because the build rewrites ownership to UID/GID 2001:2001 with empty owner/group names, changing the archive bytes from Git's 0:0 and root:root defaults.

Fix

Restore direct git archive generation with gzip -cn, removing ownership rewriting and intermediate files. Preserve artifact naming, archive prefix, source commit, timezone, and optional empty detached signatures. Update source-tarball ownership checks to expect UID/GID 0:0. SDK, symbol, and prebuilt tarball ownership normalization remains unchanged.

Fixes: dotnet/source-build#5679

Restore direct Git archive generation and expect Git's default source archive UID and GID.

Co-authored-by: Copilot App <[email protected]>
@mthalman
mthalman requested review from a team as code owners November 11, 2026 18:47
Copilot AI balanced review requested due to automatic review settings November 11, 2026 18:48
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The recursive ownership test still expects UID/GID 2001 for the source archive, which now uses 0, causing source-only validation to fail when source artifact creation is enabled.

1 open issue
What changed in this PR

Restores Git’s ownership metadata in VMR source tarballs to address release-signature mismatches, while leaving SDK, symbol, and prebuilt archive ownership normalization unchanged.

Changes:

  • Generates compressed source archives directly through git archive and gzip -cn, removing ownership rewriting and intermediate files.
  • Preserves artifact naming, archive prefix, source commit, timezone, and optional empty detached signatures.
  • Updates source-tarball ownership assertions to expect UID/GID 0:0.
File Description
test/​Microsoft.DotNet.Tests/​SourceTarballContentTests.cs Changes expected source-tarball UID/GID from 2001:2001 to 0:0.
eng/​tools/​tasks/​Microsoft.DotNet.UnifiedBuild.Tasks/​CreateSourceArtifact.cs Restores direct compressed Git archive generation and removes ownership-rewriting helpers and temporary-file handling.

Review effort: Balanced

Keep UID and GID 2001 validation for binary archives while source archives use Git's ownership metadata.

Co-authored-by: Copilot App <[email protected]>
@mthalman
mthalman requested a review from wtgodbe November 11, 2026 19:06
@mthalman
mthalman merged commit 513f589 into dotnet:main Nov 11, 2026
11 checks passed
@mthalman
mthalman deleted the mthalman-source-tarball-git-ownership branch November 11, 2026 21:50
@wtgodbe

wtgodbe commented Nov 13, 2026

Copy link
Copy Markdown
Member

/backport to release/11.0.1xx

@wtgodbe

wtgodbe commented Nov 13, 2026

Copy link
Copy Markdown
Member

/backport to release/10.0.1xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.1xx (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.1xx (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@wtgodbe backporting to release/10.0.1xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick 513f58934451232c589ddcb6aa372ae17e28c69f

Auto-merging test/Microsoft.DotNet.SourceBuild.Tests/SourceBuiltArtifactsTests.cs
CONFLICT (modify/delete): test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs deleted in HEAD and modified in 513f5893445 (Preserve Git ownership metadata in source tarballs (#10917)).  Version 513f5893445 (Preserve Git ownership metadata in source tarballs (#10917)) of test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs left in tree.
error: could not apply 513f5893445... Preserve Git ownership metadata in source tarballs (#10917)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Preserve Git ownership metadata in source tarballs
Using index info to reconstruct a base tree...
A	test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs deleted in HEAD and modified in Preserve Git ownership metadata in source tarballs.  Version Preserve Git ownership metadata in source tarballs of test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Preserve Git ownership metadata in source tarballs
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@mthalman

Copy link
Copy Markdown
Member Author

/backport to release/11.0.2xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0.2xx (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@mthalman backporting to release/11.0.2xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick 513f58934451232c589ddcb6aa372ae17e28c69f

Auto-merging test/Microsoft.DotNet.SourceBuild.Tests/SourceBuiltArtifactsTests.cs
CONFLICT (content): Merge conflict in test/Microsoft.DotNet.SourceBuild.Tests/SourceBuiltArtifactsTests.cs
Auto-merging test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs
CONFLICT (content): Merge conflict in test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs
error: could not apply 513f5893445... Preserve Git ownership metadata in source tarballs (#10917)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Preserve Git ownership metadata in source tarballs
Using index info to reconstruct a base tree...
M	eng/tools/tasks/Microsoft.DotNet.UnifiedBuild.Tasks/CreateSourceArtifact.cs
M	test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs
Falling back to patching base and 3-way merge...
Auto-merging test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs
CONFLICT (content): Merge conflict in test/Microsoft.DotNet.Tests/SourceTarballContentTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Preserve Git ownership metadata in source tarballs
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

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.

Source tarball ownership normalization breaks GitHub release signature verification

3 participants