Update clone-repos.ps1

This commit is contained in:
Markus Fleschutz 2023-10-29 12:35:39 +01:00
parent 106cda4f53
commit 79d4fc3d75
2 changed files with 63 additions and 66 deletions

View File

@ -1,30 +1,30 @@
FOLDERNAME, CATEGORY, BRANCH, SHALLOW, URL, FOLDERNAME, CATEGORY, URL, BRANCH, SHALLOW,
base256unicode, "dev tool", main, yes, "git@github.com:fleschutz/base256unicode.git", base256unicode, "dev tool", "git@github.com:fleschutz/base256unicode.git", main, yes,
bazel, "build tool", master, yes, "git@github.com:bazelbuild/bazel.git", bazel, "build tool", "https://github.com/bazelbuild/bazel", master, yes,
cmake, "build tool", master, yes, "git@github.com:Kitware/CMake.git", cmake, "build tool", "https://github.com/Kitware/CMake", master, yes,
cmatrix, "CLI fun", master, yes, "git@github.com:abishekvashok/cmatrix.git", cmatrix, "fun tool", "https://github.com/abishekvashok/cmatrix", master, yes,
cmark, "Markdown tool", master, yes, "git@github.com:commonmark/cmark.git", cmark, "Markdown tool", "https://github.com/commonmark/cmark", master, yes,
curl, "data transfer tool", master, yes, "https://github.com/curl/curl.git", curl, "data transfer tool", "https://github.com/curl/curl", master, yes,
CWTS, "dev tool", main, yes, "git@github.com:fleschutz/CWTS.git", CWTS, "dev tool", "git@github.com:fleschutz/CWTS.git", main, yes,
elasticsearch, "search tool", main, yes, "git@github.com:elastic/elasticsearch.git", elasticsearch, "search tool", "https://github.com/elastic/elasticsearch", main, yes,
kubo, "data transfer tool", master, yes, "git@github.com:ipfs/kubo.git", kubo, "data transfer tool", "https://github.com/ipfs/kubo", master, yes,
grafana, "visualization tool", main, yes, "git@github.com:grafana/grafana.git", grafana, "visualization tool", "https://github.com/grafana/grafana", main, yes,
jhead, "EXIF tool", master, yes, "git@github.com:Matthias-Wandel/jhead", jhead, "EXIF tool", "https://github.com/Matthias-Wandel/jhead", master, yes,
leon, "personal assistant", master, yes, "git@github.com:leon-ai/leon.git", leon, "personal assistant", "https://github.com/leon-ai/leon", master, yes,
llvm, "compiler", main, yes, "git@github.com:llvm/llvm-project.git", llvm, "compiler", "https://github.com/llvm/llvm-project", main, yes,
LSS, "math tool", main, yes, "git@github.com:fleschutz/LSS.git", LSS, "math tool", "git@github.com:fleschutz/LSS.git", main, yes,
ninja, "build tool", master, yes, "git@github.com:ninja-build/ninja.git", ninja, "build tool", "https://github.com/ninja-build/ninja", master, yes,
opencv, "lib", master, yes, "git@github.com:opencv/opencv.git", opencv, "dev lib", "https://github.com/opencv/opencv", master, yes,
operating-systems, "OS collection", main, yes, "git@github.com:fleschutz/operating-systems.git", operating-systems, "OS collection", "git@github.com:fleschutz/operating-systems.git", main, yes,
papers, "collection", main, yes, "git@github.com:fleschutz/papers.git", papers, "collection", "git@github.com:fleschutz/papers.git", main, yes,
PowerShell, "script collection", master, yes, "git@github.com:fleschutz/PowerShell.git", PowerShell, "script collection", "git@github.com:fleschutz/PowerShell.git", master, yes,
pwsh, "shell", master, yes, "git@github.com:PowerShell/PowerShell.git", pwsh, "shell", "https://github.com/PowerShell/PowerShell", master, yes,
protobuf, "dev", main, yes, "git@github.com:protocolbuffers/protobuf.git", protobuf, "dev lib", "https://github.com/protocolbuffers/protobuf", main, yes,
rust, "compiler", master, yes, "git@github.com:rust-lang/rust.git", rust, "compiler", "https://github.com/rust-lang/rust", master, yes,
smartmontools, "SSD/HDD tool", master, yes, "git@github.com:smartmontools/smartmontools.git", smartmontools, "SSD/HDD tool", "https://github.com/smartmontools/smartmontools", master, yes,
talk2windows, "voice tool" main, yes, "git@github.com:fleschutz/talk2windows.git", talk2windows, "voice tool", "git@github.com:fleschutz/talk2windows.git", main, yes,
tensorflow, "AI tool", master, yes, "git@github.com:tensorflow/tensorflow.git", tensorflow, "AI tool", "https://github.com/tensorflow/tensorflow", master, yes,
terminal, "desktop tool", main, yes, "git@github.com:microsoft/terminal.git", terminal, "desktop tool", "https://github.com/microsoft/terminal", main, yes,
tinycc, "compiler", mob, yes, "git@github.com:TinyCC/tinycc.git", tinycc, "compiler", "https://github.com/TinyCC/tinycc", mob, yes,
voice2json, "voice tool", master, yes, "git@github.com:synesthesiam/voice2json.git", voice2json, "voice tool", "https://github.com/synesthesiam/voice2json", master, yes,
zfs, "filesystem tool", master, yes, "git@github.com:openzfs/zfs.git", zfs, "filesystem tool", "https://github.com/openzfs/zfs", master, yes,

Can't render this file because it contains an unexpected character in line 25 and column 31.

View File

@ -2,69 +2,66 @@
.SYNOPSIS .SYNOPSIS
Clones Git repos Clones Git repos
.DESCRIPTION .DESCRIPTION
This PowerShell script clones popular Git repositories into a target directory. This PowerShell script clones popular Git repositories into a common target directory.
.PARAMETER targetDir .PARAMETER targetDir
Specifies the file path to the target directory (current working directory by default) Specifies the file path to the target directory (current working directory by default)
.EXAMPLE .EXAMPLE
PS> ./clone-repos C:\Repos PS> ./clone-repos C:\Repos
(1) Searching for Git executable... git version 2.41.0.windows.3
(2) Reading Data/popular-repositories.csv... 28 repos
(3) Checking target folder... 📂repos
(4/32) Cloning into 📂base256unicode (dev tool)...
... ...
Cloned 29 of 29 Git repos into 📂C:\Repos in 123 sec
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$TargetDir = "$PWD") param([string]$targetDir = "$PWD")
try { try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $stopWatch = [system.diagnostics.stopwatch]::startNew()
Write-Host "⏳ (1) Searching for Git executable... " -noNewline Write-Host "⏳ (1) Searching for Git executable... " -noNewline
& git --version & git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } 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" $table = Import-CSV "$PSScriptRoot/../Data/popular-repositories.csv"
$NumEntries = $Table.count $total = $table.count
Write-Host "$NumEntries repos" Write-Host "$total repos"
$TargetDirName = (Get-Item "$TargetDir").Name $targetDirName = (Get-Item "$targetDir").Name
Write-Host "⏳ (3) Checking target folder... 📂$TargetDirName" Write-Host "⏳ (3) Checking target folder... 📂$targetDirName"
if (-not(Test-Path "$TargetDir" -pathType container)) { throw "Can't access directory: $TargetDir" } if (-not(Test-Path "$targetDir" -pathType container)) { throw "Can't access directory: $targetDir" }
[int]$Step = 3 [int]$step = 3
[int]$Cloned = 0 [int]$cloned = 0
[int]$Skipped = 0 [int]$skipped = 0
foreach($Row in $Table) { foreach($row in $table) {
[string]$FolderName = $Row.FOLDERNAME [string]$folderName = $row.FOLDERNAME
[string]$Category = $Row.CATEGORY [string]$category = $row.CATEGORY
[string]$Branch = $Row.BRANCH [string]$URL = $row.URL
[string]$Shallow = $Row.SHALLOW [string]$branch = $row.BRANCH
[string]$URL = $Row.URL [string]$shallow = $row.SHALLOW
$Step++ $step++
if (Test-Path "$TargetDir/$FolderName" -pathType container) { if (Test-Path "$targetDir/$folderName" -pathType container) {
"⏳ ($Step/$($NumEntries + 4)) Skipping existing 📂$FolderName ($Category)..." "⏳ ($step/$($total + 4)) Skipping existing 📂$folderName ($category)..."
$Skipped++ $skipped++
continue continue
} }
if ($Shallow -eq "yes") { if ($shallow -eq "yes") {
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch only..." "⏳ ($step/$($total + 4)) Cloning into 📂$folderName (a $category, $branch branch, shallow)..."
& git clone --branch "$Branch" --single-branch --recurse-submodules "$URL" "$TargetDir/$FolderName" & 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" } if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
} else { } else {
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch with full history..." "⏳ ($step/$($total + 4)) Cloning into 📂$folderName (a $category, $branch branch, full history)..."
& git clone --branch "$Branch" --recurse-submodules "$URL" "$TargetDir/$FolderName" & git clone --branch "$branch" --recurse-submodules "$URL" "$targetDir/$folderName"
if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
} }
$Cloned++ $cloned++
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Cloning $Cloned of $NumEntries Git repos into folder 📂$TargetDirName took $Elapsed sec" "✔️ Cloned $cloned of $total Git repos into 📂$targetDirName in $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"