Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Text files are stored and checked out with LF on every platform, so that a Windows runner,
# a Linux runner and a developer test the same bytes (CIC-11 of the PowerShell standards).
* text=auto eol=lf

# The three scripts whose text the validation kit joins with CRLF, uploads to Intune, or hashes
# on the lab device are checked out with CRLF on every platform, as a Windows checkout had them
# before this file existed, so that a round sends the same bytes wherever it is started from.
# The kit's other scripts that are delivered to a device, such as New-IslHarnessUser.ps1, are LF
# like the rest: they are sent as they are, and nothing depends on their line endings.
Validation/Fixtures.ps1 text eol=crlf
Validation/Probe.ps1 text eol=crlf
Validation/Win32Install.ps1 text eol=crlf
31 changes: 30 additions & 1 deletion Build/Build-Help.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,36 @@ if ($null -eq $built) {
throw "Export-MamlCommandHelp produced no IntuneScriptLab-Help.xml under $maml"
}
$null = New-Item -ItemType Directory -Path $culture -Force
Copy-Item -LiteralPath $built.FullName -Destination $shipped -Force

# Export-MamlCommandHelp writes the line endings of the platform, CRLF on Windows. The committed
# file is stored and checked out with LF and CI compares a new build with it byte for byte, so
# the carriage return of every CRLF pair is dropped and the file is the same wherever it is
# built. Bytes, not text: the byte order mark and everything else stay exactly as PlatyPS wrote
# them.
$builtBytes = [System.IO.File]::ReadAllBytes($built.FullName)
$shippedStream = [System.IO.MemoryStream]::new($builtBytes.Length)
try {
# The bytes between one CRLF pair and the next are copied as a block. A carriage return that
# no line feed follows is not part of a pair and stays where it is.
$copyFrom = 0
$searchFrom = 0
while ($searchFrom -lt $builtBytes.Length) {
$carriageReturn = [Array]::IndexOf($builtBytes, [byte]13, $searchFrom)
if ($carriageReturn -lt 0) {
break
}

$searchFrom = $carriageReturn + 1
if ($searchFrom -lt $builtBytes.Length -and $builtBytes[$searchFrom] -eq 10) {
$shippedStream.Write($builtBytes, $copyFrom, $carriageReturn - $copyFrom)
$copyFrom = $searchFrom
}
}
$shippedStream.Write($builtBytes, $copyFrom, $builtBytes.Length - $copyFrom)
[System.IO.File]::WriteAllBytes($shipped, $shippedStream.ToArray())
} finally {
$shippedStream.Dispose()
}
Remove-Item -LiteralPath $maml -Recurse -Force

# Backups from Update-MarkdownCommandHelp; git holds the previous version
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ entries are carried over from the manifest's release notes.
- A `rehearsal` job in `quality-gates.yml` that runs `Build/Publish-Module.ps1 -WhatIf` on every
pull request, so that a release which would fail at the tag fails before the merge. The same
workflow now also runs every night.
- A `.gitattributes` file that checks every text file out with LF on every platform, so that a
Windows runner, a Linux runner and a developer test the same bytes. The three scripts the
validation kit uploads or runs on the lab devices keep CRLF everywhere. `Build/Build-Help.ps1`
writes the compiled help with LF wherever it runs, so a build on Windows gives the committed
file byte for byte. A release is staged from a checkout on a Windows runner, so the scripts of
a package published from now on have LF line endings where that checkout gave them CRLF, and
their file hashes differ from those of an earlier version for that reason alone.

### Changed

Expand Down