Skip to content

Commit 4ce0cbd

Browse files
Fixing issue #363 (#367)
1 parent 49d5c7f commit 4ce0cbd

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

.docs/Get-VSTeamProject.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Specifies the maximum number to return.
5959
```yaml
6060
Type: Int32
6161
Parameter Sets: List
62-
Default value: 100
6362
```
6463
6564
### Skip
@@ -69,7 +68,6 @@ Defines the number of team projects to skip. The default value is 0
6968
```yaml
7069
Type: Int32
7170
Parameter Sets: List
72-
Default value: 0
7371
```
7472
7573
### Id
@@ -99,6 +97,12 @@ Parameter Sets: ByID
9997
10098
## NOTES
10199
100+
You can use PowerShell default values to set top to any value you like.
101+
102+
$Global:PSDefaultParameterValues["*-vsteam*:top"] = 500
103+
104+
However, this function is called by the Project cache which is used by the project validation code. If the value of top is not high enough validation may fail. By default this function returns all projects.
105+
102106
<!-- #include "./common/prerequisites.md" -->
103107
104108
## RELATED LINKS

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 7.1.2
4+
5+
Changed Get-VSTeamProject to return all projects by default instead of just the top 100. This change was made to address issue #363. If your project name was not in the top 100 projects validation would fail. Returning all projects can have performance issues. You can set the value for top used by setting a PowerShell default value:
6+
7+
```powershell
8+
$Global:PSDefaultParameterValues["*-vsteam*:top"] = 500
9+
```
10+
311
## 7.1.1
412

513
Fixed bug in Test-VSTeamYamlPipeline by adding a Pipelines version value.

Source/Public/Get-VSTeamProject.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ function Get-VSTeamProject {
77
[string] $StateFilter = 'WellFormed',
88

99
[Parameter(ParameterSetName = 'List')]
10-
[int] $Top = 100,
10+
[int] $Top,
1111

1212
[Parameter(ParameterSetName = 'List')]
13-
[int] $Skip = 0,
13+
[int] $Skip,
1414

1515
[Parameter(ParameterSetName = 'ByID')]
1616
[Alias('ProjectID')]

Source/VSTeam.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'VSTeam.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '7.1.1'
15+
ModuleVersion = '7.1.2'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Core', 'Desktop')

Tests/function/tests/Get-VSTeamProject.Tests.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ Set-StrictMode -Version Latest
22

33
Describe 'VSTeamProject' {
44
BeforeAll {
5-
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath
5+
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath
66
Mock _getInstance { return 'https://dev.azure.com/test' }
77
Mock _getApiVersion { return '1.0-unitTests' } -ParameterFilter { $Service -eq 'Core' }
88
}
99

1010
Context 'Get-VSTeamProject' {
1111
BeforeAll {
12-
$env:TEAM_TOKEN = '1234'
12+
$env:TEAM_TOKEN = '1234'
1313

1414
Mock Invoke-RestMethod { Open-SampleFile 'Get-VSTeamProject.json' }
1515
Mock Invoke-RestMethod { Open-SampleFile 'Get-VSTeamProject-NamePeopleTracker.json' } -ParameterFilter {
16-
$Uri -like "*PeopleTracker*"
16+
$Uri -like "*PeopleTracker*"
1717
}
1818
}
1919

@@ -28,7 +28,6 @@ Describe 'VSTeamProject' {
2828
Should -Invoke Invoke-RestMethod -Exactly -Times 1 -Scope It -ParameterFilter {
2929
$Uri -like "*https://dev.azure.com/test/_apis/projects*" -and
3030
$Uri -like "*api-version=$(_getApiVersion Core)*" -and
31-
$Uri -like "*`$top=100*" -and
3231
$Uri -like "*stateFilter=WellFormed*"
3332
}
3433
}
@@ -52,7 +51,6 @@ Describe 'VSTeamProject' {
5251
$Uri -like "*https://dev.azure.com/test/_apis/projects*" -and
5352
$Uri -like "*api-version=$(_getApiVersion Core)*" -and
5453
$Uri -like "*`$skip=1*" -and
55-
$Uri -like "*`$top=100*" -and
5654
$Uri -like "*stateFilter=WellFormed*"
5755
}
5856
}
@@ -64,7 +62,6 @@ Describe 'VSTeamProject' {
6462
Should -Invoke Invoke-RestMethod -Exactly -Times 1 -Scope It -ParameterFilter {
6563
$Uri -like "*https://dev.azure.com/test/_apis/projects*" -and
6664
$Uri -like "*api-version=$(_getApiVersion Core)*" -and
67-
$Uri -like "*`$top=100*" -and
6865
$Uri -like "*stateFilter=All*"
6966
}
7067
}

0 commit comments

Comments
 (0)