2021-02-09 19:30:45 +01:00
|
|
|
#!/bin/powershell
|
2021-01-20 16:11:38 +01:00
|
|
|
<#
|
|
|
|
.SYNTAX ./update-repos.ps1 [<directory>]
|
2021-02-21 12:24:22 +01:00
|
|
|
.DESCRIPTION updates all Git repositories under the current/given directory (including submodules)
|
2021-01-20 16:11:38 +01:00
|
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
|
|
|
#>
|
|
|
|
|
2021-02-13 10:26:14 +01:00
|
|
|
param($Directory = "")
|
|
|
|
|
2021-02-18 20:17:55 +01:00
|
|
|
if ($Directory -eq "") {
|
|
|
|
$Directory = "$PWD"
|
|
|
|
}
|
|
|
|
|
2021-02-13 10:26:14 +01:00
|
|
|
try {
|
|
|
|
& git --version
|
|
|
|
} catch {
|
2021-02-15 12:00:23 +01:00
|
|
|
write-error "ERROR: can't execute 'git' - make sure Git is installed and available"
|
2021-02-13 10:26:14 +01:00
|
|
|
exit 1
|
|
|
|
}
|
2021-01-20 16:11:38 +01:00
|
|
|
|
|
|
|
try {
|
2021-02-16 19:06:18 +01:00
|
|
|
$Files = get-childItem -path $Directory
|
|
|
|
foreach ($File in $Files) {
|
|
|
|
if ($File.Mode -like "d*") {
|
|
|
|
$Filename = $File.Name
|
2021-01-20 16:38:46 +01:00
|
|
|
write-host ""
|
|
|
|
write-host -nonewline "Updating $Filename ..."
|
2021-01-20 16:11:38 +01:00
|
|
|
set-location $Filename
|
2021-02-13 10:26:14 +01:00
|
|
|
& git pull --recurse-submodules
|
2021-01-20 16:11:38 +01:00
|
|
|
set-location ..
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit 0
|
|
|
|
} catch {
|
2021-02-15 12:00:23 +01:00
|
|
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-01-20 16:11:38 +01:00
|
|
|
exit 1
|
|
|
|
}
|