Update clone-repos.ps1

This commit is contained in:
Markus Fleschutz 2023-12-05 08:40:27 +01:00
parent c623a07146
commit 7d34c7cdf5
2 changed files with 8 additions and 11 deletions

View File

@ -15,8 +15,6 @@ llvm, "compiler", "https://github.com/llvm/llvm-project",
LSS, "math tool", "git@github.com:fleschutz/LSS.git", main, yes,
ninja, "build tool", "https://github.com/ninja-build/ninja", master, yes,
opencv, "dev lib", "https://github.com/opencv/opencv", master, yes,
operating-systems, "OS collection", "git@github.com:fleschutz/operating-systems.git", main, yes,
papers, "collection", "git@github.com:fleschutz/papers.git", main, yes,
PowerShell, "script collection", "git@github.com:fleschutz/PowerShell.git", main, yes,
pwsh, "shell", "https://github.com/PowerShell/PowerShell", master, yes,
protobuf, "dev lib", "https://github.com/protocolbuffers/protobuf", main, yes,

1 FOLDERNAME CATEGORY URL BRANCH SHALLOW
15 LSS math tool git@github.com:fleschutz/LSS.git main yes
16 ninja build tool https://github.com/ninja-build/ninja master yes
17 opencv dev lib https://github.com/opencv/opencv master yes
operating-systems OS collection git@github.com:fleschutz/operating-systems.git main yes
papers collection git@github.com:fleschutz/papers.git main yes
18 PowerShell script collection git@github.com:fleschutz/PowerShell.git main yes
19 pwsh shell https://github.com/PowerShell/PowerShell master yes
20 protobuf dev lib https://github.com/protocolbuffers/protobuf main yes

View File

@ -6,9 +6,9 @@
.PARAMETER targetDir
Specifies the file path to the target directory (current working directory by default)
.EXAMPLE
PS> ./clone-repos C:\Repos
PS> ./clone-repos C:\MyRepos
...
Cloned 29 of 29 Git repos into 📂C:\Repos in 123 sec
Cloned 29 of 29 Git repos into 📂MyRepos in 123 sec
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -24,7 +24,7 @@ try {
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
Write-Host "⏳ (2) Reading Data/popular-repositories.csv... " -noNewline
Write-Host "⏳ (2) Reading data/popular-repositories.csv... " -noNewline
$table = Import-CSV "$PSScriptRoot/../data/popular-repositories.csv"
$total = $table.count
Write-Host "$total repos"
@ -45,23 +45,22 @@ try {
$step++
if (Test-Path "$targetDir/$folderName" -pathType container) {
"⏳ ($step/$($total + 4)) Skipping existing 📂$folderName ($category)..."
"⏳ ($step/$($total + 4)) Skipping existing 📂$folderName (a $category)..."
$skipped++
continue
}
if ($shallow -eq "yes") {
} elseif ($shallow -eq "yes") {
"⏳ ($step/$($total + 4)) Cloning into 📂$folderName (a $category, $branch branch, shallow)..."
& git clone --branch "$branch" --single-branch --recurse-submodules "$URL" "$targetDir/$folderName"
if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
$cloned++
} else {
"⏳ ($step/$($total + 4)) Cloning into 📂$folderName (a $category, $branch branch, full history)..."
& git clone --branch "$branch" --recurse-submodules "$URL" "$targetDir/$folderName"
if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
$clone++
}
$cloned++
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Cloned $cloned of $total Git repos into 📂$targetDirName in $Elapsed sec"
"✔️ Cloned $cloned of $total Git repos into 📂$targetDirName in $elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"