Skip to content

Commit b1b3c47

Browse files
authored
Merge branch 'main' into anshuldube-patch-1
2 parents 10422ab + 0c51488 commit b1b3c47

File tree

4 files changed

+24978
-50
lines changed

4 files changed

+24978
-50
lines changed

.build/Build.ps1

+19-7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ New-Item -Path $distFolder -ItemType Directory | Out-Null
2828
$scriptFiles = Get-ChildItem -Path $repoRoot -Directory |
2929
Where-Object { $_.Name -ne ".build" } |
3030
ForEach-Object { Get-ChildItem -Path $_.FullName *.ps1 -Recurse } |
31-
Where-Object {! $_.Name.Contains(".Tests.ps1")}
32-
Sort-Object Name |
31+
Where-Object { ! $_.Name.Contains(".Tests.ps1") }
32+
Sort-Object Name |
3333
ForEach-Object { $_.FullName }
3434

3535
$nonUnique = @($scriptFiles | ForEach-Object { [IO.Path]::GetFileName($_) } | Group-Object | Where-Object { $_.Count -gt 1 })
@@ -107,7 +107,7 @@ $scriptFiles | ForEach-Object {
107107
$linesToInsert += ""
108108
$linesToInsert += "`$$($m.Matches[0].Groups[1].Value) = [Convert]::FromBase64String(`$$($m.Matches[0].Groups[1].Value)Base64)"
109109
$scriptContent.InsertRange($i, $linesToInsert)
110-
$commitTimeTest = [DateTime]::Parse((git log -n 1 --format="%ad" --date=rfc $dotloadedScriptPath))
110+
$commitTimeTest = [DateTime]::Parse((git log -n 1 --format="%ad" --date=rfc $filePath))
111111

112112
if ($commitTimeTest -gt $commitTime) {
113113
$commitTime = $commitTimeTest
@@ -116,11 +116,23 @@ $scriptFiles | ForEach-Object {
116116
}
117117
}
118118

119-
Write-Host ("Setting version for script '$_' to '$($commitTime.ToString("yy.MM.dd.HHmm"))'")
120-
$version = "# Version $($commitTime.ToString("yy.MM.dd.HHmm"))"
121-
# Stamp version
119+
$buildVersionString = $commitTime.ToString("yy.MM.dd.HHmm")
120+
Write-Host ("Setting version for script '$_' to $buildVersionString")
121+
122+
# Set version variable if present
123+
for ($i = 0; $i -lt $scriptContent.Count; $i++) {
124+
$line = $scriptContent[$i]
125+
if ($line.Contains("`$BuildVersion = `"`"")) {
126+
$newLine = $line.Replace("`$BuildVersion = `"`"", "`$BuildVersion = `"$buildVersionString`"")
127+
Write-Host $newLine
128+
$scriptContent.RemoveAt($i)
129+
$scriptContent.Insert($i, $newLine)
130+
}
131+
}
132+
133+
# Stamp version in comments
122134
$scriptContent.Insert(0, "")
123-
$scriptContent.Insert(0, $version)
135+
$scriptContent.Insert(0, "# Version $buildVersionString")
124136

125137
# Add disclaimer
126138
$scriptContent.Insert(0, "")

0 commit comments

Comments
 (0)