diff options
| author | Thomas Schmucker <ts@its1.de> | 2026-07-28 08:17:31 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2026-07-28 08:17:31 +0200 |
| commit | 24b2283b318fb0e68342e77c13ab220f77db4de1 (patch) | |
| tree | 340bf7159a8abf6ef25ee61d2389f5b6d1e39c0c /bootstrap-win/git.ps1 | |
| parent | 6b347041dabee4b128b8778041d6ab8158fb0d13 (diff) | |
| download | dotfiles-24b2283b318fb0e68342e77c13ab220f77db4de1.tar.gz dotfiles-24b2283b318fb0e68342e77c13ab220f77db4de1.tar.bz2 dotfiles-24b2283b318fb0e68342e77c13ab220f77db4de1.zip | |
bootstrap: git.sh und git.ps1 hinzugefuegt (git + delta), Doku angepasst
Diffstat (limited to 'bootstrap-win/git.ps1')
| -rw-r--r-- | bootstrap-win/git.ps1 | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/bootstrap-win/git.ps1 b/bootstrap-win/git.ps1 new file mode 100644 index 0000000..41a3112 --- /dev/null +++ b/bootstrap-win/git.ps1 | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | #Requires -Version 5.1 | ||
| 2 | <# | ||
| 3 | Installiert Git und delta (Pager fuer git/config) per winget. | ||
| 4 | |||
| 5 | Aufruf (keine Admin-Rechte noetig): | ||
| 6 | .\bootstrap-win\git.ps1 | ||
| 7 | #> | ||
| 8 | |||
| 9 | $ErrorActionPreference = "Stop" | ||
| 10 | $script:Failures = @() | ||
| 11 | |||
| 12 | function Write-Ok($msg) { | ||
| 13 | Write-Host "OK $msg" -ForegroundColor Green | ||
| 14 | } | ||
| 15 | |||
| 16 | function Write-Step($msg) { | ||
| 17 | Write-Host "==> $msg" -ForegroundColor Cyan | ||
| 18 | } | ||
| 19 | |||
| 20 | function Write-Skip($msg) { | ||
| 21 | Write-Host "- $msg bereits vorhanden" -ForegroundColor DarkGray | ||
| 22 | } | ||
| 23 | |||
| 24 | function Write-Warn($msg) { | ||
| 25 | Write-Host "! $msg" -ForegroundColor Yellow | ||
| 26 | $script:Failures += $msg | ||
| 27 | } | ||
| 28 | |||
| 29 | function Test-CommandExists([string]$Name) { | ||
| 30 | return [bool](Get-Command $Name -ErrorAction SilentlyContinue) | ||
| 31 | } | ||
| 32 | |||
| 33 | function Install-WingetPackage([string]$Binary, [string]$Id) { | ||
| 34 | if (Test-CommandExists $Binary) { | ||
| 35 | Write-Skip $Binary | ||
| 36 | return | ||
| 37 | } | ||
| 38 | |||
| 39 | Write-Step "winget install $Id" | ||
| 40 | $output = winget install --id $Id -e --source winget --accept-package-agreements --accept-source-agreements --silent 2>&1 | ||
| 41 | |||
| 42 | if ($LASTEXITCODE -ne 0) { | ||
| 43 | $lastLine = ($output | Select-Object -Last 3) -join " / " | ||
| 44 | Write-Warn "winget install $Id fehlgeschlagen (Binary '$Binary' nicht gefunden): $lastLine -- Pruefen mit: winget search $Id" | ||
| 45 | return | ||
| 46 | } | ||
| 47 | |||
| 48 | Write-Ok $Id | ||
| 49 | } | ||
| 50 | |||
| 51 | function Test-Prerequisites { | ||
| 52 | if (-not (Test-CommandExists "winget")) { | ||
| 53 | Write-Host "Fehler: winget wurde nicht gefunden. 'App Installer' aus dem Microsoft Store installieren." -ForegroundColor Red | ||
| 54 | exit 1 | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | function Main { | ||
| 59 | Test-Prerequisites | ||
| 60 | |||
| 61 | Install-WingetPackage -Binary "git" -Id "Git.Git" | ||
| 62 | Install-WingetPackage -Binary "delta" -Id "dandavison.delta" | ||
| 63 | |||
| 64 | Write-Host "" | ||
| 65 | if ($script:Failures.Count -eq 0) { | ||
| 66 | Write-Host "Bootstrap abgeschlossen." -ForegroundColor Green | ||
| 67 | } else { | ||
| 68 | Write-Host "Bootstrap abgeschlossen, mit $($script:Failures.Count) Warnung(en):" -ForegroundColor Yellow | ||
| 69 | foreach ($f in $script:Failures) { | ||
| 70 | Write-Host " - $f" -ForegroundColor Yellow | ||
| 71 | } | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | Main | ||
