-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_powershell.ps1
More file actions
99 lines (86 loc) · 3.81 KB
/
setup_powershell.ps1
File metadata and controls
99 lines (86 loc) · 3.81 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env pwsh
# gitrid PowerShell Setup Script
# This script installs gitrid for PowerShell on Windows
Write-Host "gitrid PowerShell Setup" -ForegroundColor Green
Write-Host "=========================" -ForegroundColor Green
# Check if WSL is available
Write-Host "Checking WSL availability..." -ForegroundColor Yellow
try {
$wslCheck = wsl --list --quiet 2>$null
if ($LASTEXITCODE -eq 0) {
Write-Host "✓ WSL is available" -ForegroundColor Green
} else {
Write-Host "✗ WSL is not available or not properly configured" -ForegroundColor Red
Write-Host "Please install WSL before using gitrid on Windows" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "✗ WSL is not available or not properly configured" -ForegroundColor Red
Write-Host "Please install WSL before using gitrid on Windows" -ForegroundColor Red
exit 1
}
# Define paths
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$SourceBat = Join-Path $ScriptDir "gitrid.bat"
$DestinationBat = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps\gitrid.bat"
# Check if source batch file exists
if (-not (Test-Path $SourceBat)) {
Write-Host "✗ gitrid.bat not found in current directory" -ForegroundColor Red
Write-Host "Please run this script from the gitrid directory" -ForegroundColor Red
exit 1
}
# Check if gitrid is already installed
if (Test-Path $DestinationBat) {
Write-Host "gitrid is already installed. Updating..." -ForegroundColor Yellow
# Check current version
try {
$currentVersion = & gitrid --version 2>$null
Write-Host "Current version: $currentVersion" -ForegroundColor Cyan
} catch {
Write-Host "Could not determine current version" -ForegroundColor Yellow
}
} else {
Write-Host "Installing gitrid for PowerShell..." -ForegroundColor Yellow
}
# Copy the batch file to WindowsApps directory
try {
Copy-Item $SourceBat $DestinationBat -Force
Write-Host "✓ gitrid.bat copied to $DestinationBat" -ForegroundColor Green
} catch {
Write-Host "✗ Failed to copy gitrid.bat: $_" -ForegroundColor Red
exit 1
}
# Verify WSL script exists and is up to date
Write-Host "Checking WSL installation..." -ForegroundColor Yellow
try {
$wslScriptPath = "/usr/local/bin/gitrid.sh"
$wslVersion = wsl sh -c "grep 'VERSION=' $wslScriptPath 2>/dev/null || echo 'NOT_FOUND'"
if ($wslVersion -eq "NOT_FOUND") {
Write-Host "WSL script not found. Please run setup_linux.sh in WSL first." -ForegroundColor Red
exit 1
}
Write-Host "✓ WSL script found: $wslVersion" -ForegroundColor Green
} catch {
Write-Host "✗ Could not verify WSL installation: $_" -ForegroundColor Yellow
Write-Host "Please ensure gitrid is properly installed in WSL" -ForegroundColor Yellow
}
# Test the installation
Write-Host "Testing gitrid installation..." -ForegroundColor Yellow
try {
$testVersion = & gitrid --version
Write-Host "✓ gitrid is working: $testVersion" -ForegroundColor Green
} catch {
Write-Host "✗ gitrid test failed: $_" -ForegroundColor Red
Write-Host "Please check your WSL installation and PATH" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "Installation completed successfully!" -ForegroundColor Green
Write-Host "You can now use 'gitrid' from PowerShell" -ForegroundColor Green
Write-Host ""
Write-Host "Usage examples:" -ForegroundColor Cyan
Write-Host " gitrid --help # Show help" -ForegroundColor White
Write-Host " gitrid --version # Show version" -ForegroundColor White
Write-Host " gitrid feature/ # Delete branches matching pattern" -ForegroundColor White
Write-Host " gitrid --merged feature/ # Delete merged branches matching pattern" -ForegroundColor White
Write-Host " gitrid --list # List all branches with status" -ForegroundColor White