diff --git a/.gitignore b/.gitignore index 27eff06..f21ec4c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ DerivedDataCache/ *.suo *.opensdf *.sdf + +# Local credentials +.env.local diff --git a/AGENTS.md b/AGENTS.md index 06d7f72..2ba9dbb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -96,6 +96,18 @@ Recent commits: - `72b9174` - Add LED remote control dashboard - `148ffec` - Proxy dashboard API through web server - `ae97ea7` - Keep remote control responsive in background +- `ae011fe` - Add AI agent project context + +## Public Repository + +Primary public Forgejo repository: + +- Web: `http://192.168.170.41:3000/post/ledcube3d` +- Git remote: `http://192.168.170.41:3000/post/ledcube3d.git` +- Suggested local remote name: `forgejo` + +Local credentials are stored on this machine in `.env.local`, which must remain ignored and uncommitted. +Use `Scripts/PushForgejo.ps1` to push with the local token without putting the token into `.git/config`. ## Important Working Tree Rules diff --git a/Scripts/PushForgejo.ps1 b/Scripts/PushForgejo.ps1 new file mode 100644 index 0000000..0fa20f9 --- /dev/null +++ b/Scripts/PushForgejo.ps1 @@ -0,0 +1,37 @@ +param( + [string]$RemoteName = "forgejo", + [string]$Branch = "main" +) + +$ErrorActionPreference = "Stop" + +$projectRoot = Split-Path -Parent $PSScriptRoot +$envFile = Join-Path $projectRoot ".env.local" +if (-not (Test-Path -LiteralPath $envFile)) { + throw "Missing .env.local with FORGEJO_URL, FORGEJO_USER, FORGEJO_TOKEN, and FORGEJO_REPO." +} + +$values = @{} +Get-Content -LiteralPath $envFile | ForEach-Object { + if ($_ -match "^\s*([^#=]+?)\s*=\s*(.*)\s*$") { + $values[$matches[1]] = $matches[2] + } +} + +foreach ($name in @("FORGEJO_URL", "FORGEJO_USER", "FORGEJO_TOKEN", "FORGEJO_REPO")) { + if (-not $values.ContainsKey($name) -or [string]::IsNullOrWhiteSpace($values[$name])) { + throw "Missing $name in .env.local." + } +} + +$repoUrl = "$($values.FORGEJO_URL.TrimEnd('/'))/$($values.FORGEJO_REPO).git" +$remoteUrl = git -C $projectRoot remote get-url $RemoteName 2>$null +if ($LASTEXITCODE -ne 0) { + git -C $projectRoot remote add $RemoteName $repoUrl +} elseif ($remoteUrl -ne $repoUrl) { + git -C $projectRoot remote set-url $RemoteName $repoUrl +} + +$pair = "$($values.FORGEJO_USER):$($values.FORGEJO_TOKEN)" +$auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair)) +git -C $projectRoot -c "http.extraHeader=Authorization: Basic $auth" push $RemoteName $Branch