From 24b2283b318fb0e68342e77c13ab220f77db4de1 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Tue, 28 Jul 2026 08:17:31 +0200 Subject: bootstrap: git.sh und git.ps1 hinzugefuegt (git + delta), Doku angepasst --- bootstrap-win/git.ps1 | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 bootstrap-win/git.ps1 (limited to 'bootstrap-win/git.ps1') 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 @@ +#Requires -Version 5.1 +<# + Installiert Git und delta (Pager fuer git/config) per winget. + + Aufruf (keine Admin-Rechte noetig): + .\bootstrap-win\git.ps1 +#> + +$ErrorActionPreference = "Stop" +$script:Failures = @() + +function Write-Ok($msg) { + Write-Host "OK $msg" -ForegroundColor Green +} + +function Write-Step($msg) { + Write-Host "==> $msg" -ForegroundColor Cyan +} + +function Write-Skip($msg) { + Write-Host "- $msg bereits vorhanden" -ForegroundColor DarkGray +} + +function Write-Warn($msg) { + Write-Host "! $msg" -ForegroundColor Yellow + $script:Failures += $msg +} + +function Test-CommandExists([string]$Name) { + return [bool](Get-Command $Name -ErrorAction SilentlyContinue) +} + +function Install-WingetPackage([string]$Binary, [string]$Id) { + if (Test-CommandExists $Binary) { + Write-Skip $Binary + return + } + + Write-Step "winget install $Id" + $output = winget install --id $Id -e --source winget --accept-package-agreements --accept-source-agreements --silent 2>&1 + + if ($LASTEXITCODE -ne 0) { + $lastLine = ($output | Select-Object -Last 3) -join " / " + Write-Warn "winget install $Id fehlgeschlagen (Binary '$Binary' nicht gefunden): $lastLine -- Pruefen mit: winget search $Id" + return + } + + Write-Ok $Id +} + +function Test-Prerequisites { + if (-not (Test-CommandExists "winget")) { + Write-Host "Fehler: winget wurde nicht gefunden. 'App Installer' aus dem Microsoft Store installieren." -ForegroundColor Red + exit 1 + } +} + +function Main { + Test-Prerequisites + + Install-WingetPackage -Binary "git" -Id "Git.Git" + Install-WingetPackage -Binary "delta" -Id "dandavison.delta" + + Write-Host "" + if ($script:Failures.Count -eq 0) { + Write-Host "Bootstrap abgeschlossen." -ForegroundColor Green + } else { + Write-Host "Bootstrap abgeschlossen, mit $($script:Failures.Count) Warnung(en):" -ForegroundColor Yellow + foreach ($f in $script:Failures) { + Write-Host " - $f" -ForegroundColor Yellow + } + } +} + +Main -- cgit v1.3