mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 07:53:21 +01:00
Update clone-repos.ps1
This commit is contained in:
parent
106cda4f53
commit
79d4fc3d75
@ -1,30 +1,30 @@
|
||||
FOLDERNAME, CATEGORY, BRANCH, SHALLOW, URL,
|
||||
base256unicode, "dev tool", main, yes, "git@github.com:fleschutz/base256unicode.git",
|
||||
bazel, "build tool", master, yes, "git@github.com:bazelbuild/bazel.git",
|
||||
cmake, "build tool", master, yes, "git@github.com:Kitware/CMake.git",
|
||||
cmatrix, "CLI fun", master, yes, "git@github.com:abishekvashok/cmatrix.git",
|
||||
cmark, "Markdown tool", master, yes, "git@github.com:commonmark/cmark.git",
|
||||
curl, "data transfer tool", master, yes, "https://github.com/curl/curl.git",
|
||||
CWTS, "dev tool", main, yes, "git@github.com:fleschutz/CWTS.git",
|
||||
elasticsearch, "search tool", main, yes, "git@github.com:elastic/elasticsearch.git",
|
||||
kubo, "data transfer tool", master, yes, "git@github.com:ipfs/kubo.git",
|
||||
grafana, "visualization tool", main, yes, "git@github.com:grafana/grafana.git",
|
||||
jhead, "EXIF tool", master, yes, "git@github.com:Matthias-Wandel/jhead",
|
||||
leon, "personal assistant", master, yes, "git@github.com:leon-ai/leon.git",
|
||||
llvm, "compiler", main, yes, "git@github.com:llvm/llvm-project.git",
|
||||
LSS, "math tool", main, yes, "git@github.com:fleschutz/LSS.git",
|
||||
ninja, "build tool", master, yes, "git@github.com:ninja-build/ninja.git",
|
||||
opencv, "lib", master, yes, "git@github.com:opencv/opencv.git",
|
||||
operating-systems, "OS collection", main, yes, "git@github.com:fleschutz/operating-systems.git",
|
||||
papers, "collection", main, yes, "git@github.com:fleschutz/papers.git",
|
||||
PowerShell, "script collection", master, yes, "git@github.com:fleschutz/PowerShell.git",
|
||||
pwsh, "shell", master, yes, "git@github.com:PowerShell/PowerShell.git",
|
||||
protobuf, "dev", main, yes, "git@github.com:protocolbuffers/protobuf.git",
|
||||
rust, "compiler", master, yes, "git@github.com:rust-lang/rust.git",
|
||||
smartmontools, "SSD/HDD tool", master, yes, "git@github.com:smartmontools/smartmontools.git",
|
||||
talk2windows, "voice tool" main, yes, "git@github.com:fleschutz/talk2windows.git",
|
||||
tensorflow, "AI tool", master, yes, "git@github.com:tensorflow/tensorflow.git",
|
||||
terminal, "desktop tool", main, yes, "git@github.com:microsoft/terminal.git",
|
||||
tinycc, "compiler", mob, yes, "git@github.com:TinyCC/tinycc.git",
|
||||
voice2json, "voice tool", master, yes, "git@github.com:synesthesiam/voice2json.git",
|
||||
zfs, "filesystem tool", master, yes, "git@github.com:openzfs/zfs.git",
|
||||
FOLDERNAME, CATEGORY, URL, BRANCH, SHALLOW,
|
||||
base256unicode, "dev tool", "git@github.com:fleschutz/base256unicode.git", main, yes,
|
||||
bazel, "build tool", "https://github.com/bazelbuild/bazel", master, yes,
|
||||
cmake, "build tool", "https://github.com/Kitware/CMake", master, yes,
|
||||
cmatrix, "fun tool", "https://github.com/abishekvashok/cmatrix", master, yes,
|
||||
cmark, "Markdown tool", "https://github.com/commonmark/cmark", master, yes,
|
||||
curl, "data transfer tool", "https://github.com/curl/curl", master, yes,
|
||||
CWTS, "dev tool", "git@github.com:fleschutz/CWTS.git", main, yes,
|
||||
elasticsearch, "search tool", "https://github.com/elastic/elasticsearch", main, yes,
|
||||
kubo, "data transfer tool", "https://github.com/ipfs/kubo", master, yes,
|
||||
grafana, "visualization tool", "https://github.com/grafana/grafana", main, yes,
|
||||
jhead, "EXIF tool", "https://github.com/Matthias-Wandel/jhead", master, yes,
|
||||
leon, "personal assistant", "https://github.com/leon-ai/leon", master, yes,
|
||||
llvm, "compiler", "https://github.com/llvm/llvm-project", main, yes,
|
||||
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", master, yes,
|
||||
pwsh, "shell", "https://github.com/PowerShell/PowerShell", master, yes,
|
||||
protobuf, "dev lib", "https://github.com/protocolbuffers/protobuf", main, yes,
|
||||
rust, "compiler", "https://github.com/rust-lang/rust", master, yes,
|
||||
smartmontools, "SSD/HDD tool", "https://github.com/smartmontools/smartmontools", master, yes,
|
||||
talk2windows, "voice tool", "git@github.com:fleschutz/talk2windows.git", main, yes,
|
||||
tensorflow, "AI tool", "https://github.com/tensorflow/tensorflow", master, yes,
|
||||
terminal, "desktop tool", "https://github.com/microsoft/terminal", main, yes,
|
||||
tinycc, "compiler", "https://github.com/TinyCC/tinycc", mob, yes,
|
||||
voice2json, "voice tool", "https://github.com/synesthesiam/voice2json", master, yes,
|
||||
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.
|
@ -2,69 +2,66 @@
|
||||
.SYNOPSIS
|
||||
Clones Git repos
|
||||
.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
|
||||
Specifies the file path to the target directory (current working directory by default)
|
||||
.EXAMPLE
|
||||
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
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$TargetDir = "$PWD")
|
||||
param([string]$targetDir = "$PWD")
|
||||
|
||||
try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
Write-Host "⏳ (1) Searching for Git executable... " -noNewline
|
||||
& 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
|
||||
$Table = Import-CSV "$PSScriptRoot/../Data/popular-repositories.csv"
|
||||
$NumEntries = $Table.count
|
||||
Write-Host "$NumEntries repos"
|
||||
$table = Import-CSV "$PSScriptRoot/../Data/popular-repositories.csv"
|
||||
$total = $table.count
|
||||
Write-Host "$total repos"
|
||||
|
||||
$TargetDirName = (Get-Item "$TargetDir").Name
|
||||
Write-Host "⏳ (3) Checking target folder... 📂$TargetDirName"
|
||||
if (-not(Test-Path "$TargetDir" -pathType container)) { throw "Can't access directory: $TargetDir" }
|
||||
$targetDirName = (Get-Item "$targetDir").Name
|
||||
Write-Host "⏳ (3) Checking target folder... 📂$targetDirName"
|
||||
if (-not(Test-Path "$targetDir" -pathType container)) { throw "Can't access directory: $targetDir" }
|
||||
|
||||
[int]$Step = 3
|
||||
[int]$Cloned = 0
|
||||
[int]$Skipped = 0
|
||||
foreach($Row in $Table) {
|
||||
[string]$FolderName = $Row.FOLDERNAME
|
||||
[string]$Category = $Row.CATEGORY
|
||||
[string]$Branch = $Row.BRANCH
|
||||
[string]$Shallow = $Row.SHALLOW
|
||||
[string]$URL = $Row.URL
|
||||
$Step++
|
||||
[int]$step = 3
|
||||
[int]$cloned = 0
|
||||
[int]$skipped = 0
|
||||
foreach($row in $table) {
|
||||
[string]$folderName = $row.FOLDERNAME
|
||||
[string]$category = $row.CATEGORY
|
||||
[string]$URL = $row.URL
|
||||
[string]$branch = $row.BRANCH
|
||||
[string]$shallow = $row.SHALLOW
|
||||
$step++
|
||||
|
||||
if (Test-Path "$TargetDir/$FolderName" -pathType container) {
|
||||
"⏳ ($Step/$($NumEntries + 4)) Skipping existing 📂$FolderName ($Category)..."
|
||||
$Skipped++
|
||||
if (Test-Path "$targetDir/$folderName" -pathType container) {
|
||||
"⏳ ($step/$($total + 4)) Skipping existing 📂$folderName ($category)..."
|
||||
$skipped++
|
||||
continue
|
||||
}
|
||||
if ($Shallow -eq "yes") {
|
||||
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch only..."
|
||||
& 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 ($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" }
|
||||
} else {
|
||||
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch with 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" }
|
||||
"⏳ ($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" }
|
||||
}
|
||||
$Cloned++
|
||||
$cloned++
|
||||
}
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Cloning $Cloned of $NumEntries Git repos into folder 📂$TargetDirName took $Elapsed sec"
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Cloned $cloned of $total Git repos into 📂$targetDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user