-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit.ps1
68 lines (58 loc) · 1.22 KB
/
commit.ps1
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
param (
[string[]]$params,
[string]$b1,
[string]$b2
)
if (-not $b1 -or -not $b2) {
Write-Host "Error: Branch names not provided. Use -b1 [branch1] -b2 [branch2]"
exit 1
}
# Combine all params into a single string
$commitParams = $params -join " "
# Checkout b1
git checkout $b1
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to checkout $b1"
exit 1
}
# Add changes
git add .
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to add changes"
exit 1
}
# Commit changes
Invoke-Expression "git commit $commitParams"
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to commit changes"
exit 1
}
# Push changes
git push
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to push changes"
exit 1
}
# Checkout b2
git checkout $b2
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to checkout $b2"
exit 1
}
# Cherry-pick changes from b1
git cherry-pick $b1
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to cherry-pick changes from $b1"
exit 1
}
# Push changes
git push
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to push changes"
exit 1
}
git checkout $b1
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to checkout $b1"
exit 1
}