Skip to content

Commit 1f0224a

Browse files
authored
Rename destinationFolder parameter to targetFolder for consistency in Update-Repos.ps1 script (#21)
1 parent 4674c73 commit 1f0224a

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

PowerShell/Update-Repos.ps1

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
.DESCRIPTION
66
This script clones or updates GitHub repositories for a specified organization into a specified destination folder.
77
8-
.PARAMETER destinationFolder
8+
.PARAMETER targetFolder
99
The folder where the repositories will be cloned or updated.
1010
1111
.PARAMETER organization
@@ -27,7 +27,7 @@
2727
Purpose/Change: Initial script development
2828
2929
.EXAMPLE
30-
Get-GitHubRepos -destinationFolder "Git/Folder1" -organization "Azure" -repos @("repo1", "repo2")
30+
Get-GitHubRepos -targetFolder "Git/Folder1" -organization "Azure" -repos @("repo1", "repo2")
3131
3232
.EXAMPLE
3333
$tfrepos = gh repo list azure -L 5000 --json name --jq '.[].name' | Select-String -Pattern "terraform-azurerm-avm"
@@ -40,7 +40,7 @@ function Update-GitHubRepos {
4040
param
4141
(
4242
[Parameter()]
43-
[string]$destinationFolder,
43+
[string]$targetFolder,
4444
[Parameter()]
4545
[string]$organization,
4646
[Parameter()]
@@ -54,7 +54,7 @@ function Update-GitHubRepos {
5454
}
5555

5656
foreach ($repo in $repos) {
57-
$repoPath = Join-Path -Path $destinationFolder -ChildPath "$organization/$repo"
57+
$repoPath = Join-Path -Path $targetFolder -ChildPath "$organization/$repo"
5858
If (!(Test-Path -Path $repoPath)) {
5959
if ($PSCmdlet.ShouldProcess("Cloning repository $repo into $repoPath")) {
6060
New-Item -ItemType Directory -Path $repoPath -Force
@@ -92,7 +92,7 @@ function Update-GitHubRepos {
9292
.PARAMETER organization
9393
The Azure DevOps organization name.
9494
95-
.PARAMETER destinationFolder
95+
.PARAMETER targetFolder
9696
The folder where the repositories will be cloned or updated.
9797
9898
.PARAMETER pat
@@ -111,7 +111,7 @@ function Update-GitHubRepos {
111111
Purpose/Change: Initial script development
112112
113113
.EXAMPLE
114-
CloneUpdate-AdoRepos.ps1 -organization "yourOrg" -destinationFolder "C:\Repos" -pat "yourPAT"
114+
CloneUpdate-AdoRepos.ps1 -organization "yourOrg" -targetFolder "C:\Repos" -pat "yourPAT"
115115
#>
116116

117117
function Update-AdoRepos {
@@ -122,7 +122,7 @@ function Update-AdoRepos {
122122
[Parameter()]
123123
[string]$organization,
124124
[Parameter()]
125-
[string]$destinationFolder,
125+
[string]$targetFolder,
126126
[Parameter()]
127127
[string]$pat
128128
)
@@ -170,7 +170,7 @@ function Update-AdoRepos {
170170
$projects = Get-AdoProjects -organization $organization -pat $pat
171171
Write-Output "Found $($projects.Count) projects: $($projects.name)"
172172
foreach ($project in $projects) {
173-
$projectFolder = "$destinationFolder/$($project.name)"
173+
$projectFolder = "$targetFolder/$($project.name)"
174174
if (-not (Test-Path -Path $projectFolder)) {
175175
if ($PSCmdlet.ShouldProcess("Creating folder $projectFolder")) {
176176
Write-Output "Creating folder $projectFolder"
@@ -246,11 +246,17 @@ function Update-Repos {
246246
[string]$pat
247247
)
248248

249+
# Resolve destinationFolder to an absolute path
250+
if (-not $destinationFolder) {
251+
throw "The destinationFolder parameter cannot be empty."
252+
}
253+
$destinationFolder = Resolve-Path -Path $destinationFolder | ForEach-Object { $_.Path }
254+
249255
if ($pat) {
250256
Write-Output "- Updating Azure DevOps repositories"
251-
Update-AdoRepos -organization $organization -destinationFolder $destinationFolder -pat $pat
257+
Update-AdoRepos -organization $organization -targetFolder $destinationFolder -pat $pat
252258
} else {
253259
Write-Output "- Updating GitHub repositories"
254-
Update-GitHubRepos -destinationFolder $destinationFolder -organization $organization -repos $repos
260+
Update-GitHubRepos -targetFolder $destinationFolder -organization $organization -repos $repos
255261
}
256262
}

0 commit comments

Comments
 (0)