Show unseen Server commits after login.
Bake first-parent git log at Server build and remember the SHA in a browser cookie. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# UTF-8 first-parent log for HSchool.Server. Keep in sync with embed-changelog.sh.
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $RepoRoot,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $Output
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$dir = Split-Path -Parent $Output
|
||||
if (-not (Test-Path -LiteralPath $dir)) {
|
||||
New-Item -ItemType Directory -Path $dir | Out-Null
|
||||
}
|
||||
|
||||
$sha = ""
|
||||
$log = ""
|
||||
Push-Location -LiteralPath $RepoRoot
|
||||
try {
|
||||
$sha = (git rev-parse HEAD 2>$null | Out-String).Trim()
|
||||
if ($LASTEXITCODE -ne 0 -or $sha.Length -ne 40) {
|
||||
$sha = ""
|
||||
}
|
||||
elseif ($sha.Length -eq 40) {
|
||||
$log = git -c core.quotepath=false log --first-parent --encoding=UTF-8 --pretty=format:%H%x1f%cI%x1f%s
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
$log = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$text = $sha + "`n"
|
||||
if (-not [string]::IsNullOrEmpty($log)) {
|
||||
$text += $log.TrimEnd() + "`n"
|
||||
}
|
||||
|
||||
[System.IO.File]::WriteAllText($Output, $text, [System.Text.UTF8Encoding]::new($false))
|
||||
Reference in New Issue
Block a user