PowerShell/Scripts/clone-repos.ps1

30 lines
715 B
PowerShell
Raw Normal View History

2020-12-01 12:24:56 +01:00
#!/snap/bin/powershell
2020-12-29 15:14:21 +01:00
<#
.SYNTAX ./clone-repos.ps1
.DESCRIPTION clones well-known Git repositories into the current directory.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
2020-12-01 12:24:56 +01:00
2021-01-20 16:11:38 +01:00
$PathToRepo = "$PSScriptRoot/.."
2020-12-01 12:24:56 +01:00
2020-12-09 10:30:55 +01:00
try {
2021-01-20 16:11:38 +01:00
$Table = import-csv "$PathToRepo/Data/repos.csv"
foreach($Row in $Table) {
$URL = $Row.URL
2021-01-21 15:19:24 +01:00
$Directory = $Row.Directory
2021-01-20 16:11:38 +01:00
write-output ""
2021-01-21 15:19:24 +01:00
if (Test-Path($Directory)) {
write-output "Skipping $Directory (already existent) ..."
continue
}
2021-01-20 16:38:46 +01:00
write-output "Cloning from $URL..."
2021-02-04 11:39:50 +01:00
git clone --recurse-submodules $URL
2020-12-01 12:24:56 +01:00
}
2020-12-09 10:30:55 +01:00
exit 0
} catch {
2020-12-25 11:30:43 +01:00
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-09 10:30:55 +01:00
exit 1
}