-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush.ps1
More file actions
45 lines (37 loc) · 1.61 KB
/
Copy pathpush.ps1
File metadata and controls
45 lines (37 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Push LemonTop to github.com/cbigeagle/LemonTop. Safe to re-run.
#
# .\push.ps1 # commits everything with a default message
# .\push.ps1 "fix sparkline" # commits everything with your message
#
param([string]$Message = "Update LemonTop")
$ErrorActionPreference = "Stop"
# Keep native exit codes as data; git uses them for answers, not just failures.
$PSNativeCommandUseErrorActionPreference = $false
Set-Location $PSScriptRoot
$Repo = "cbigeagle/LemonTop"
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
throw "gh CLI not found - install from https://cli.github.com"
}
gh auth status *> $null
if ($LASTEXITCODE -ne 0) { throw "Not logged in - run: gh auth login" }
if (-not (Test-Path .git)) { git init -b main }
# git refuses to commit without an author name, and the global config has none.
if (-not (git config user.name)) { git config user.name (gh api user --jq .login) }
if (-not (git config user.email)) { git config user.email (gh api user --jq .email) }
git add -A
git diff --cached --quiet
if ($LASTEXITCODE -eq 0) { "Nothing to commit." } else { git commit -m $Message }
git remote get-url origin *> $null
if ($LASTEXITCODE -ne 0) {
gh repo view $Repo *> $null
if ($LASTEXITCODE -eq 0) {
git remote add origin "https://github.com/$Repo.git"
}
else {
gh repo create $Repo --public --source=. --remote=origin `
--description "A btop-style terminal monitor for Lemonade Server"
}
}
git push -u origin (git branch --show-current)
if ($LASTEXITCODE -ne 0) { throw "Push rejected - see the git message above." }
"Done: https://github.com/$Repo"