Added update-repos.ps1

This commit is contained in:
Markus Fleschutz
2021-01-20 16:11:38 +01:00
parent 4bc3339db9
commit 15a98fd9d1
5 changed files with 50 additions and 6 deletions

View File

@ -6,14 +6,16 @@
.NOTES Author: Markus Fleschutz / License: CC0
#>
$Repos = "https://github.com/commonmark/cmark", "https://github.com/opencv/opencv", "https://github.com/openzfs/zfs", "https://github.com/synesthesiam/voice2json", "https://github.com/fleschutz/CWTS", "https://github.com/fleschutz/cubesum", "https://github.com/fleschutz/PowerShell","https://github.com/fleschutz/CWTS", "https://github.com/fleschutz/eventdriven"
$PathToRepo = "$PSScriptRoot/.."
try {
foreach ($Repo in $Repos) {
$Answer = read-host "Do you want to clone $Repo (y/n)"
if ($Answer -eq "y") {
git clone $Repo
}
$Table = import-csv "$PathToRepo/Data/repos.csv"
foreach($Row in $Table) {
$URL = $Row.URL
write-output ""
write-output "Cloning $URL..."
git clone $URL
}
write-output "Done."

29
Scripts/update-repos.ps1 Executable file
View File

@ -0,0 +1,29 @@
#!/snap/bin/powershell
<#
.SYNTAX ./update-repos.ps1 [<directory>]
.DESCRIPTION updates all Git repositories under the current directory
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Directory = "")
try {
if ($Directory -eq "") {
$Directory = "$PWD"
}
$Items = get-childItem -path $Directory
foreach ($Item in $Items) {
if ($Item.Mode -eq "d-----") {
$Filename = $Item.Name
set-location $Filename
git pull
set-location ..
}
}
write-output "Done."
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}