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))
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# UTF-8 first-parent log for HSchool.Server. Keep in sync with embed-changelog.ps1.
|
||||
set -e
|
||||
RepoRoot=$1
|
||||
Output=$2
|
||||
if [ -z "$RepoRoot" ] || [ -z "$Output" ]; then
|
||||
echo "usage: embed-changelog.sh <repo-root> <output>" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$(dirname "$Output")"
|
||||
sha=
|
||||
log=
|
||||
if sha=$(git -C "$RepoRoot" rev-parse HEAD 2>/dev/null) && [ "${#sha}" -eq 40 ]; then
|
||||
log=$(git -C "$RepoRoot" -c core.quotepath=false log --first-parent --encoding=UTF-8 --pretty=format:%H%x1f%cI%x1f%s) || log=
|
||||
else
|
||||
sha=
|
||||
fi
|
||||
{
|
||||
printf '%s\n' "$sha"
|
||||
if [ -n "$log" ]; then
|
||||
printf '%s\n' "$log"
|
||||
fi
|
||||
} > "$Output"
|
||||
Reference in New Issue
Block a user