Add shallow cloning to clone-repos.ps1

This commit is contained in:
Markus Fleschutz
2021-06-30 18:36:58 +02:00
parent 7509212f69
commit e0acb18f6d
3 changed files with 35 additions and 29 deletions

View File

@ -15,21 +15,27 @@ try {
$Null = (git --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
$Table = import-csv "$PSScriptRoot/../Data/git-repositories.csv"
$Table = import-csv "$PSScriptRoot/../Data/git-repos.csv"
[int]$Count = 0
foreach($Row in $Table) {
$AppName = $Row.AppName
$FolderName = $Row.FolderName
$BranchName = $Row.BranchName
$URL = $Row.URL
[string]$AppName = $Row.AppName
[string]$FolderName = $Row.FolderName
[string]$Branch = $Row.Branch
[string]$Shallow = $Row.Shallow
[string]$URL = $Row.URL
if (test-path "$ParentDir/$FolderName" -pathType container) {
"📂$FolderName exists, skipping..."
continue
}
"🢃 Cloning $AppName into 📂$FolderName, $BranchName branch..."
& git clone --branch "$BranchName" --recurse-submodules "$URL" "$ParentDir/$FolderName"
if ($Shallow -eq "yes") {
"🢃 Cloning $AppName into 📂$FolderName, $Branch branch, shallow..."
& git clone --branch "$Branch" --depth 1 --shallow-submodules --recurse-submodules "$URL" "$ParentDir/$FolderName"
} else {
"🢃 Cloning $AppName into 📂$FolderName, $Branch branch, full history..."
& git clone --branch "$Branch" --recurse-submodules "$URL" "$ParentDir/$FolderName"
}
if ($lastExitCode -ne "0") { throw "'git clone $URL' failed" }
$Count++
}