-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloneReposV3.ps1
More file actions
47 lines (36 loc) · 1.13 KB
/
cloneReposV3.ps1
File metadata and controls
47 lines (36 loc) · 1.13 KB
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
45
46
47
$repos = @(
"https://github.com/keshavsoft/BackEndGenerator",
"https://github.com/keshavsoft/kschema"
)
# ---------- base folder ----------
$baseFolder = "D:\KeshavSoftRepos"
# ---------- today folder ----------
$todayFolder = Get-Date -Format "yyyy-MM-dd"
# ---------- final target ----------
$targetFolder = Join-Path $baseFolder $todayFolder
# ---------- create base folder ----------
if (!(Test-Path $baseFolder)) {
New-Item -ItemType Directory -Path $baseFolder
}
# ---------- stop if workspace already exists ----------
if (Test-Path $targetFolder) {
Write-Host "Workspace already exists : $targetFolder"
exit
}
# ---------- create today folder ----------
New-Item -ItemType Directory -Path $targetFolder
# ---------- move into target ----------
Set-Location $targetFolder
# ---------- clone repos ----------
foreach ($repo in $repos) {
$repoName = ($repo.Split("/") | Select-Object -Last 1)
if (Test-Path $repoName) {
Write-Host "$repoName already exists"
}
else {
Write-Host "Cloning $repoName ..."
git clone $repo
}
}
Write-Host ""
Write-Host "Workspace ready : $targetFolder"