-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclone-all.ps1
44 lines (33 loc) · 1.12 KB
/
clone-all.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
param([string]$rootDevDir)
# Validate script parameters
if ([string]::IsNullOrWhiteSpace($rootDevDir)) {
$rootDevDir = Get-Location
}
# Script Constants
Set-Variable githubOrgSite -Option Constant -Scope Script -Value "https://github.com/gemstone"
Set-Variable reposFile -Option Constant -Scope Script -Value "repos.txt"
# Script Functions
function Clone-Repository($url) {
& git clone $url
}
# Load repo list from repos.txt - this is expected to be in desired build dependency order
$repos = [IO.File]::ReadAllLines("$rootDevDir\$reposFile")
# Remove any comment lines from loaded repo list
$repos = $repos | Where-Object { -not $_.Trim().StartsWith("::") }
# Separate repos names from project names
for ($i = 0; $i -lt $repos.Length; $i++){
$parts = $repos[$i].Trim().Split('/');
if ($parts.Length -eq 2) {
$repos[$i] = $parts[0].Trim()
}
else {
$repos[$i] = ""
}
}
$repos = $repos | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }
Set-Location ".."
# Clone all repositories
foreach ($repo in $repos) {
Clone-Repository "$githubOrgSite/$repo.git"
}
Set-Location $rootDevDir