-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.ps1
More file actions
72 lines (63 loc) · 1.87 KB
/
commit.ps1
File metadata and controls
72 lines (63 loc) · 1.87 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
<#
.SYNOPSIS
Build and commit script for PrintMaster
.DESCRIPTION
Runs build.ps1 both before attempting to commit. Only commits if the build succeeds.
.PARAMETER Message
The commit message (required)
.PARAMETER Push
Optional switch to push after committing
.EXAMPLE
.\commit.ps1 -Message "Fix scanner timeout issue"
.\commit.ps1 "Fix scanner timeout issue" -Push
#>
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$Message,
[switch]$Push
)
$ErrorActionPreference = "Stop"
Write-Host "=== PrintMaster Commit Script ===" -ForegroundColor Cyan
Write-Host ""
# Step 1: Run build
Write-Host "[1/3] Building agent and server..." -ForegroundColor Yellow
try {
& "$PSScriptRoot\build.ps1" both
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed with exit code $LASTEXITCODE" -ForegroundColor Red
exit 1
}
} catch {
Write-Host "Build failed: $_" -ForegroundColor Red
exit 1
}
Write-Host "Build succeeded!" -ForegroundColor Green
Write-Host ""
# Step 2: Stage and commit
Write-Host "[2/3] Staging and committing changes..." -ForegroundColor Yellow
git add -A
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to stage changes" -ForegroundColor Red
exit 1
}
git commit -m $Message
if ($LASTEXITCODE -ne 0) {
Write-Host "Commit failed (nothing to commit?)" -ForegroundColor Red
exit 1
}
Write-Host "Committed successfully!" -ForegroundColor Green
Write-Host ""
# Step 3: Push (optional)
if ($Push) {
Write-Host "[3/3] Pushing to remote..." -ForegroundColor Yellow
git push
if ($LASTEXITCODE -ne 0) {
Write-Host "Push failed" -ForegroundColor Red
exit 1
}
Write-Host "Pushed successfully!" -ForegroundColor Green
} else {
Write-Host "[3/3] Skipping push (use -Push to push automatically)" -ForegroundColor DarkGray
}
Write-Host ""
Write-Host "=== Done ===" -ForegroundColor Cyan