Files
PDF-Downloaders/recreate-on-gitea.ps1
T

60 lines
1.9 KiB
PowerShell

# Recreate PDF-Downloaders on a fresh Gitea server, then push local history.
#
# Prerequisites:
# 1. Gitea is running (e.g. https://git.masengr.com or http://tower:3000 via Tailscale)
# 2. You created an EMPTY repo: Michael-A-Sloan/PDF-Downloaders
# (or update $Owner / $RepoName below)
# 3. Sign in when Git Credential Manager prompts (username + Personal Access Token)
#
# Usage:
# .\recreate-on-gitea.ps1
# .\recreate-on-gitea.ps1 -RemoteUrl "http://tower:3000/Michael-A-Sloan/PDF-Downloaders.git"
param(
[string]$RemoteUrl = "https://git.masengr.com/Michael-A-Sloan/PDF-Downloaders.git"
)
$ErrorActionPreference = "Stop"
$RepoRoot = $PSScriptRoot
Set-Location $RepoRoot
Write-Host "=== Recreate / push PDF-Downloaders ===" -ForegroundColor Cyan
Write-Host "Remote: $RemoteUrl"
Write-Host ""
if (-not (Test-Path ".git")) {
throw "Not a git repo. Run this from PDF-Downloaders."
}
$existing = git remote 2>$null
if ($existing -notcontains "origin") {
git remote add origin $RemoteUrl
} else {
git remote set-url origin $RemoteUrl
}
Write-Host "Checking remote..."
$probe = git ls-remote origin HEAD 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host "Remote repo not found or not authenticated yet." -ForegroundColor Yellow
Write-Host "Do this first:"
Write-Host " 1. Open Gitea in the browser"
Write-Host " 2. Create repository: PDF-Downloaders (empty, no README)"
Write-Host " 3. Owner/org: Michael-A-Sloan"
Write-Host " 4. Re-run this script (sign in with username + token when prompted)"
Write-Host ""
Write-Host "Tailscale URL example:"
Write-Host " .\recreate-on-gitea.ps1 -RemoteUrl `"http://tower:3000/Michael-A-Sloan/PDF-Downloaders.git`""
Write-Host ""
Write-Host "Git said: $probe"
exit 1
}
Write-Host "Pushing main..." -ForegroundColor Cyan
git push -u origin main
Write-Host ""
Write-Host "Done." -ForegroundColor Green
Write-Host " Web: $($RemoteUrl -replace '\.git$','')"