-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit-push.ps1
More file actions
38 lines (31 loc) · 1002 Bytes
/
commit-push.ps1
File metadata and controls
38 lines (31 loc) · 1002 Bytes
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
param([string]$msg)
# 1. Detect submodule path (first entry in .gitmodules)
$submodulePath = Get-Content ".gitmodules" |
Select-String "path\s*=" |
ForEach-Object { ($_ -split " = ")[1].Trim() }
if (-not $submodulePath) {
Write-Host "No submodule found." ; exit 1
}
###########################################################################
function ACP {
param([string]$message)
git diff --cached --quiet
if ($LASTEXITCODE -ne 0) {
git commit -m $message ; if ($LASTEXITCODE) { exit 1 }
git push ; if ($LASTEXITCODE) { exit 1 }
} else {
Write-Host "No changes to commit here."
}
}
###########################################################################
# 2. SUBMODULE
Write-Host "Processing submodule '$submodulePath'..."
Push-Location $submodulePath
git add -A
ACP $msg
Pop-Location
# 3. MAIN REPO
Write-Host "Processing main repo..."
git add -A
ACP "Update submodule + misc: $msg"
Write-Host "All done!"