Configure Forgejo repository access
This commit is contained in:
parent
ae011fec6b
commit
493693c94b
3 changed files with 52 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -8,3 +8,6 @@ DerivedDataCache/
|
|||
*.suo
|
||||
*.opensdf
|
||||
*.sdf
|
||||
|
||||
# Local credentials
|
||||
.env.local
|
||||
|
|
|
|||
12
AGENTS.md
12
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
|
||||
|
||||
|
|
|
|||
37
Scripts/PushForgejo.ps1
Normal file
37
Scripts/PushForgejo.ps1
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue