Skip to content

Commit 497e982

Browse files
authored
Merge branch 'main' into copilot/add-signing-for-top-level-containers
2 parents b793381 + f890dfe commit 497e982

10 files changed

Lines changed: 113 additions & 23 deletions

File tree

.github/workflows/inter-branch-merge-base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
if: steps.extract-configuration-values.outputs.configurationFound != 'true'
7272
name: Read configuration status
7373

74-
- run: ${{ github.workspace }}\arcade-repository\.github\workflows\scripts\inter-branch-merge.ps1 -RepoName ${{ steps.fetch-repo-name.outputs.repository_name }} -RepoOwner ${{ github.repository_owner }} -MergeFromBranch $env:GITHUB_REF_NAME -MergeToBranch ${{ steps.extract-configuration-values.outputs.mergeToBranch }} ${{ steps.extract-configuration-values.outputs.mergeSwitchArguments }}
74+
- run: ${{ github.workspace }}\arcade-repository\.github\workflows\scripts\inter-branch-merge.ps1 -RepoName ${{ steps.fetch-repo-name.outputs.repository_name }} -RepoOwner ${{ github.repository_owner }} -MergeFromBranch $env:GITHUB_REF_NAME -MergeToBranch ${{ steps.extract-configuration-values.outputs.mergeToBranch }} -ResetToTargetPaths "${{ steps.extract-configuration-values.outputs.resetToTargetPaths }}" ${{ steps.extract-configuration-values.outputs.mergeSwitchArguments }}
7575
if: steps.extract-configuration-values.outputs.configurationFound == 'true'
7676
name: Merge branches
7777
working-directory: ${{ github.workspace }}/repository

.github/workflows/scripts/inter-branch-merge.ps1

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ The current branch
1515
Create a PR even if the only commits are from dotnet-maestro[bot]
1616
.PARAMETER QuietComments
1717
Do not tag commiters, do not comment on PR updates. Reduces GitHub notifications
18+
.PARAMETER ResetToTargetPaths
19+
Semicolon-separated list of glob patterns for files to reset to the target branch version.
20+
After the merge branch is created, files matching these patterns will be checked out from
21+
the target branch and committed, resolving potential merge conflicts for these files.
1822
#>
1923
[CmdletBinding(SupportsShouldProcess = $true)]
2024
param(
@@ -36,7 +40,10 @@ param(
3640

3741
[switch]$AllowAutomatedCommits,
3842

39-
[switch]$QuietComments
43+
[switch]$QuietComments,
44+
45+
[Alias('r')]
46+
[string]$ResetToTargetPaths = ""
4047
)
4148

4249
$ErrorActionPreference = 'stop'
@@ -105,6 +112,62 @@ function GetCommitterGitHubName($sha) {
105112
return $null
106113
}
107114

115+
function ResetFilesToTargetBranch($patterns, $targetBranch) {
116+
if (-not $patterns -or $patterns.Count -eq 0) {
117+
return
118+
}
119+
120+
Write-Host "Resetting files to $targetBranch for patterns: $($patterns -join ', ')"
121+
122+
# Verify the target branch exists
123+
$branchExists = & git rev-parse --verify "origin/$targetBranch" 2>&1
124+
if ($LASTEXITCODE -ne 0) {
125+
Write-Warning "Target branch 'origin/$targetBranch' does not exist. Skipping file reset."
126+
return
127+
}
128+
129+
foreach ($pattern in $patterns) {
130+
$pattern = $pattern.Trim()
131+
if (-not $pattern) {
132+
continue
133+
}
134+
135+
Write-Host "Processing pattern: $pattern"
136+
137+
# Use git checkout to reset files matching the pattern to the target branch
138+
# The -- is needed to separate the revision from the pathspec
139+
try {
140+
# First check if there are any files matching the pattern in the target branch
141+
$matchingFiles = & git ls-tree -r --name-only "origin/$targetBranch" -- $pattern 2>&1
142+
if ($LASTEXITCODE -ne 0) {
143+
Write-Warning "Failed to list files for pattern '$pattern': $matchingFiles"
144+
continue
145+
}
146+
147+
if ($matchingFiles) {
148+
Write-Host "Found files matching pattern '$pattern': $($matchingFiles -join ', ')"
149+
Invoke-Block { & git checkout "origin/$targetBranch" -- $pattern }
150+
151+
# Check if there are any changes to commit
152+
$status = & git status --porcelain
153+
if ($status) {
154+
# Add all changes (the checkout already modified the specific files)
155+
Invoke-Block { & git add -A }
156+
Invoke-Block { & git commit -m "Reset '$pattern' to $targetBranch" }
157+
Write-Host -f Green "Successfully reset '$pattern' to $targetBranch"
158+
} else {
159+
Write-Host "No changes to commit for pattern '$pattern'"
160+
}
161+
} else {
162+
Write-Host -f Yellow "No files found matching pattern '$pattern' in $targetBranch"
163+
}
164+
}
165+
catch {
166+
Write-Warning "Failed to reset pattern '$pattern' to $targetBranch. Error: $_"
167+
}
168+
}
169+
}
170+
108171
# see https://git-scm.com/docs/pretty-formats
109172
$formatString = '%h %cn <%ce>: %s (%cr)'
110173

@@ -151,6 +214,12 @@ try {
151214
$mergeBranchName = "merge/$MergeFromBranch-to-$MergeToBranch"
152215
Invoke-Block { & git checkout -B $mergeBranchName }
153216

217+
# Reset specified files to target branch if ResetToTargetPaths is configured
218+
if ($ResetToTargetPaths) {
219+
$patterns = $ResetToTargetPaths -split ";"
220+
ResetFilesToTargetBranch $patterns $MergeToBranch
221+
}
222+
154223
$remoteName = 'origin'
155224
$prOwnerName = $RepoOwner
156225
$prRepoName = $RepoName

.github/workflows/scripts/read-configuration.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,15 @@ if ($configuration -ne $null) {
9898
$ExtraSwitches = $configuration['ExtraSwitches']
9999
}
100100

101+
$ResetToTargetPaths = "";
102+
if($configuration.ContainsKey('ResetToTargetPaths')){
103+
# Convert array to semicolon-separated string for output
104+
$ResetToTargetPaths = $configuration['ResetToTargetPaths'] -join ";"
105+
}
106+
101107
"mergeSwitchArguments=$ExtraSwitches" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
102108
"mergeToBranch=$MergeToBranch" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
109+
"resetToTargetPaths=$ResetToTargetPaths" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
103110
"configurationFound=$true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
104111
}
105112

azure-pipelines-daily.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ stages:
2929
version: 8.x
3030
installationPath: $(System.DefaultWorkingDirectory)/.dotnet
3131

32-
- script: $(System.DefaultWorkingDirectory)/.dotnet/dotnet.exe tool restore
32+
- script: dotnet tool restore
3333
displayName: Restore dotnet tools
3434

3535
- task: AzureCLI@2

eng/Version.Details.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
3-
<Source Uri="https://github.com/dotnet/dotnet" Mapping="arcade" Sha="d119b40e8ff3b88f87ad60b04c807233a159b197" BarId="292184" />
3+
<Source Uri="https://github.com/dotnet/dotnet" Mapping="arcade" Sha="29eefe27a350eb8b0bcbababa7863a0d1086295d" BarId="293166" />
44
<ProductDependencies>
55
</ProductDependencies>
66
<ToolsetDependencies>

eng/common/core-templates/job/source-index-stage1.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ parameters:
33
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
44
preSteps: []
55
binlogPath: artifacts/log/Debug/Build.binlog
6-
condition: ''
6+
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
77
dependsOn: ''
88
pool: ''
99
is1ESPipeline: ''
@@ -41,4 +41,4 @@ jobs:
4141

4242
- template: /eng/common/core-templates/steps/source-index-stage1-publish.yml
4343
parameters:
44-
binLogPath: ${{ parameters.binLogPath }}
44+
binLogPath: ${{ parameters.binLogPath }}

eng/common/tools.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
157157
return $global:_DotNetInstallDir
158158
}
159159

160-
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
161-
$env:DOTNET_MULTILEVEL_LOOKUP=0
162-
163160
# Disable first run since we do not need all ASP.NET packages restored.
164161
$env:DOTNET_NOLOGO=1
165162

@@ -225,7 +222,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
225222
# Make Sure that our bootstrapped dotnet cli is available in future steps of the Azure Pipelines build
226223
Write-PipelinePrependPath -Path $dotnetRoot
227224

228-
Write-PipelineSetVariable -Name 'DOTNET_MULTILEVEL_LOOKUP' -Value '0'
229225
Write-PipelineSetVariable -Name 'DOTNET_NOLOGO' -Value '1'
230226

231227
return $global:_DotNetInstallDir = $dotnetRoot

eng/common/tools.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ function InitializeDotNetCli {
115115

116116
local install=$1
117117

118-
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
119-
export DOTNET_MULTILEVEL_LOOKUP=0
120-
121118
# Disable first run since we want to control all package sources
122119
export DOTNET_NOLOGO=1
123120

@@ -166,7 +163,6 @@ function InitializeDotNetCli {
166163
# build steps from using anything other than what we've downloaded.
167164
Write-PipelinePrependPath -path "$dotnet_root"
168165

169-
Write-PipelineSetVariable -name "DOTNET_MULTILEVEL_LOOKUP" -value "0"
170166
Write-PipelineSetVariable -name "DOTNET_NOLOGO" -value "1"
171167

172168
# return value

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "10.0.100-rc.2.25502.107",
3+
"version": "10.0.100",
44
"rollForward": "latestFeature",
55
"paths": [
66
".dotnet",
@@ -9,7 +9,7 @@
99
"errorMessage": "The required .NET SDK wasn't found. Please run ./eng/common/dotnet.cmd/sh to install it."
1010
},
1111
"tools": {
12-
"dotnet": "10.0.100-rc.2.25502.107"
12+
"dotnet": "10.0.100"
1313
},
1414
"msbuild-sdks": {
1515
"Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.25570.6",

src/Microsoft.DotNet.SignTool/src/ZipData.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ private string GetUpdatedControlArchive(TaskLoggingHelper log, string debianPack
584584
Directory.CreateDirectory(dataLayout);
585585

586586
// Get the original control archive - to reuse package metadata and scripts
587-
var entry = ReadDebContainerEntries(debianPackage, "control.tar").Single();
588-
string controlArchive = Path.Combine(workingDir, entry.RelativePath);
589-
entry.WriteToFile(controlArchive);
587+
var controlEntry = ReadDebContainerEntries(debianPackage, "control.tar").Single();
588+
string controlArchive = Path.Combine(workingDir, controlEntry.RelativePath);
589+
controlEntry.WriteToFile(controlArchive);
590590

591591
ExtractTarballContents(log, dataArchive, dataLayout);
592592
ExtractTarballContents(log, controlArchive, controlLayout);
@@ -619,11 +619,33 @@ private string GetUpdatedControlArchive(TaskLoggingHelper log, string debianPack
619619
File.WriteAllText(controlFile, fileContents);
620620
}
621621

622-
// Repack the control tarball
623-
using (var dstStream = File.Open(controlArchive, FileMode.Create))
622+
// Update the control tarball contents. We update the contents of the control entry streams
623+
// rather than recreating from the unpacked directory layout to ensure that
624+
// the original entry field metadata and tar format is preserved.
625+
using MemoryStream streamToCompress = new();
626+
using (TarWriter writer = new(streamToCompress, leaveOpen: true))
624627
{
625-
using var gzip = new GZipStream(dstStream, CompressionMode.Compress);
626-
TarFile.CreateFromDirectory(controlLayout, gzip, includeBaseDirectory: false);
628+
foreach (TarEntry entry in ReadTarGZipEntries(controlArchive))
629+
{
630+
string relativeName = entry.Name;
631+
if (relativeName is "./control" or "./md5sums")
632+
{
633+
using FileStream fileStream = File.OpenRead(Path.Combine(controlLayout, relativeName));
634+
entry.DataStream = fileStream;
635+
entry.DataStream.Position = 0;
636+
writer.WriteEntry(entry);
637+
continue;
638+
}
639+
640+
writer.WriteEntry(entry);
641+
}
642+
}
643+
644+
streamToCompress.Position = 0;
645+
using (FileStream outputStream = File.Open(controlArchive, FileMode.Create))
646+
{
647+
using GZipStream compressor = new(outputStream, CompressionMode.Compress);
648+
streamToCompress.CopyTo(compressor);
627649
}
628650

629651
return controlArchive;

0 commit comments

Comments
 (0)