Skip to content

Commit 8350a4c

Browse files
Merge branch 'master' into rawTelemetry
2 parents 0ae4426 + a1ba15e commit 8350a4c

21 files changed

+260
-162
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Need to make sure that this file always has consistent line endings since we store the hash
2+
# of it in GitHubConfiguration.ps1 in order to be able to determine if it has been modified
3+
# or not.
4+
Tests/Config/Settings.ps1 text eol=crlf

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ This module supports testing using the [Pester UT framework](https://github.com/
295295
To install it:
296296

297297
```powershell
298-
Install-Module -Name Pester
298+
Install-Module -Name Pester -RequiredVersion 4.10.1 -AllowClobber -SkipPublisherCheck -Force
299299
```
300300

301301
#### Configuring Your Environment

GitHubBranches.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function Get-GitHubRepositoryBranch
8989
'RepositoryName' = (Get-PiiSafeString -PlainText $RepositoryName)
9090
}
9191

92-
$uriFragment = "repos/$OwnerName/$RepositoryName/branches`?"
92+
$uriFragment = "repos/$OwnerName/$RepositoryName/branches"
9393
if (-not [String]::IsNullOrEmpty($Name)) { $uriFragment = $uriFragment + "/$Name" }
9494

9595
$getParams = @()

GitHubCore.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,11 @@ function Invoke-GHRestMethodMultipleResult
665665
}
666666

667667
$result = Invoke-GHRestMethod @params
668-
$finalResult += $result.result
668+
if ($null -ne $result.result)
669+
{
670+
$finalResult += $result.result
671+
}
672+
669673
$nextLink = $result.nextLink
670674
$currentDescription = "$Description (getting additional results)"
671675
}
@@ -679,8 +683,7 @@ function Invoke-GHRestMethodMultipleResult
679683
Set-TelemetryEvent -EventName $TelemetryEventName -Properties $TelemetryProperties -Metrics $telemetryMetrics
680684
}
681685

682-
# Ensure we're always returning our results as an array, even if there is a single result.
683-
return @($finalResult)
686+
return $finalResult
684687
}
685688
catch
686689
{

GitHubRepositories.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function New-GitHubRepository
4141
4242
.PARAMETER Private
4343
By default, this repository will created Public. Specify this to create
44-
a private repository. Creating private repositories requires a paid GitHub account.
44+
a private repository.
4545
4646
.PARAMETER NoIssues
4747
By default, this repository will support Issues. Specify this to disable Issues.
@@ -139,7 +139,7 @@ function New-GitHubRepository
139139
$uriFragment = "orgs/$OrganizationName/repos"
140140
}
141141

142-
if ($PSBoundParameters.ContainsKey('TeamId') -and (-not $PSBoundParameters.Contains('OrganizationName')))
142+
if ($PSBoundParameters.ContainsKey('TeamId') -and (-not $PSBoundParameters.ContainsKey('OrganizationName')))
143143
{
144144
$message = 'TeamId may only be specified when creating a repository under an organization.'
145145
Write-Log -Message $message -Level Error
@@ -710,8 +710,7 @@ function Update-GitHubRepository
710710
Update the default branch for this repository.
711711
712712
.PARAMETER Private
713-
Specify this to make the repository repository. Creating private repositories requires a
714-
paid GitHub account.
713+
Specify this to make the repository private.
715714
To change a repository to be public, specify -Private:$false
716715
717716
.PARAMETER NoIssues

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# PowerShellForGitHub PowerShell Module
22

3-
[![[GitHub version]](https://badge.fury.io/gh/microsoft%2FPowerShellForGitHub.svg)](https://badge.fury.io/gh/microsoft%2FPowerShellForGitHub)
3+
[![[GitHub version]](https://badge.fury.io/gh/microsoft%2FPowerShellForGitHub.svg)](https://github.com/microsoft/PowerShellForGitHub/releases)
4+
[![powershellgallery](https://img.shields.io/powershellgallery/v/PowerShellForGitHub)](https://www.powershellgallery.com/packages/PowerShellForGitHub)
5+
[![downloads](https://img.shields.io/powershellgallery/dt/PowerShellForGitHub.svg?label=downloads)](https://www.powershellgallery.com/packages/PowerShellForGitHub)
6+
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/microsoft/PowerShellForGitHub)
7+
[![downloads](https://img.shields.io/badge/license-MIT-green)](https://github.com/HowardWolosky/PowerShellForGitHub/blob/master/LICENSE)
8+
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3990/badge)](https://bestpractices.coreinfrastructure.org/projects/3990)
9+
[![tweet](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FQuackFu)](https://twitter.com/intent/tweet?text=%23PowerShellForGitHub%20%40QuackFu%20&original_referer=https://github.com/microsoft/PowerShellForGitHub)
10+
<br />
411
[![Build status](https://dev.azure.com/ms/PowerShellForGitHub/_apis/build/status/PowerShellForGitHub-CI?branchName=master)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
12+
[![Azure DevOps tests](https://img.shields.io/azure-devops/tests/ms/PowerShellForGitHub/109)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
13+
[![Azure DevOps coverage](https://img.shields.io/azure-devops/coverage/ms/PowerShellForGitHub/109)](https://dev.azure.com/ms/PowerShellForGitHub/_build/latest?definitionId=109&branchName=master)
14+
<br />
15+
[![Help Wanted Issues](https://img.shields.io/github/issues/microsoft/PowerShellForGitHub/help%20wanted)](https://github.com/microsoft/PowerShellForGitHub/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
16+
[![GitHub last commit](https://img.shields.io/github/last-commit/microsoft/PowerShellForGitHub)](https://github.com/HowardWolosky/PowerShellForGitHub/commits/master)
517

618
#### Table of Contents
719

@@ -15,6 +27,7 @@
1527
* [Legal and Licensing](#legal-and-licensing)
1628
* [Governance](#governance)
1729
* [Code of Conduct](#code-of-conduct)
30+
* [Reporting Security Issues](#reporting-security-issues)
1831
* [Privacy Policy](#privacy-policy)
1932

2033
----------
@@ -159,6 +172,12 @@ For more info, see [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md)
159172

160173
----------
161174

175+
## Reporting Security Issues
176+
177+
Please refer to [SECURITY.md](./SECURITY.md).
178+
179+
----------
180+
162181
## Privacy Policy
163182

164183
For more information, refer to Microsoft's [Privacy Policy](https://go.microsoft.com/fwlink/?LinkID=521839).

SECURITY.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.1 BLOCK -->
2+
3+
## Security
4+
5+
Microsoft takes the security of our software products and services seriously, which includes all
6+
source code repositories managed through our GitHub organizations, which include
7+
[Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure),
8+
[DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet),
9+
[Xamarin](https://github.com/xamarin), and [many more](https://opensource.microsoft.com/).
10+
11+
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets
12+
Microsoft's [definition](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10))
13+
of a security vulnerability, please report it to us as described below.
14+
15+
## Reporting Security Issues
16+
17+
**Please do not report security vulnerabilities through public GitHub issues.** Instead, please
18+
report them to the Microsoft Security Response Center at [[email protected]](mailto:[email protected]).
19+
If possible, encrypt your message with our PGP key; please download it from the
20+
[Microsoft Security Response Center PGP Key page](https://technet.microsoft.com/en-us/security/dn606155).
21+
22+
You should receive a response within 24 hours. If for some reason you do not, please follow up via
23+
email to ensure we received your original message. Additional information can be found at
24+
[microsoft.com/msrc](https://www.microsoft.com/msrc).
25+
26+
Please include the requested information listed below (as much as you can provide) to help us better
27+
understand the nature and scope of the possible issue:
28+
29+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
30+
* Full paths of source file(s) related to the manifestation of the issue
31+
* The location of the affected source code (tag/branch/commit or direct URL)
32+
* Any special configuration required to reproduce the issue
33+
* Step-by-step instructions to reproduce the issue
34+
* Proof-of-concept or exploit code (if possible)
35+
* Impact of the issue, including how an attacker might exploit the issue
36+
37+
This information will help us triage your report more quickly.
38+
39+
## Preferred Languages
40+
41+
We prefer all communications to be in English.
42+
43+
## Policy
44+
45+
Microsoft follows the principle of
46+
[Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
47+
48+
<!-- END MICROSOFT SECURITY.MD BLOCK -->

Tests/GitHubAnalytics.tests.ps1

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ try
1616
$repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid) -AutoInit
1717

1818
Context 'When initially created, there are no issues' {
19-
$issues = Get-GitHubIssue -Uri $repo.svn_url
19+
$issues = @(Get-GitHubIssue -Uri $repo.svn_url)
2020

2121
It 'Should return expected number of issues' {
22-
@($issues).Count | Should be 0
22+
$issues.Count | Should be 0
2323
}
2424
}
2525

@@ -34,29 +34,29 @@ try
3434
$newIssues[0] = Update-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[0].number -State Closed
3535
$newIssues[-1] = Update-GitHubIssue -OwnerName $script:ownerName -RepositoryName $repo.name -Issue $newIssues[-1].number -State Closed
3636

37-
$issues = Get-GitHubIssue -Uri $repo.svn_url
37+
$issues = @(Get-GitHubIssue -Uri $repo.svn_url)
3838
It 'Should return only open issues' {
39-
@($issues).Count | Should be 2
39+
$issues.Count | Should be 2
4040
}
4141

42-
$issues = Get-GitHubIssue -Uri $repo.svn_url -State All
42+
$issues = @(Get-GitHubIssue -Uri $repo.svn_url -State All)
4343
It 'Should return all issues' {
44-
@($issues).Count | Should be 4
44+
$issues.Count | Should be 4
4545
}
4646

4747
$createdOnOrAfterDate = Get-Date -Date $newIssues[0].created_at
4848
$createdOnOrBeforeDate = Get-Date -Date $newIssues[2].created_at
49-
$issues = (Get-GitHubIssue -Uri $repo.svn_url) | Where-Object { ($_.created_at -ge $createdOnOrAfterDate) -and ($_.created_at -le $createdOnOrBeforeDate) }
49+
$issues = @((Get-GitHubIssue -Uri $repo.svn_url) | Where-Object { ($_.created_at -ge $createdOnOrAfterDate) -and ($_.created_at -le $createdOnOrBeforeDate) })
5050

5151
It 'Smart object date conversion works for comparing dates' {
52-
@($issues).Count | Should be 2
52+
$issues.Count | Should be 2
5353
}
5454

5555
$createdDate = Get-Date -Date $newIssues[1].created_at
56-
$issues = Get-GitHubIssue -Uri $repo.svn_url -State All | Where-Object { ($_.created_at -ge $createdDate) -and ($_.state -eq 'closed') }
56+
$issues = @(Get-GitHubIssue -Uri $repo.svn_url -State All | Where-Object { ($_.created_at -ge $createdDate) -and ($_.state -eq 'closed') })
5757

5858
It 'Able to filter based on date and state' {
59-
@($issues).Count | Should be 1
59+
$issues.Count | Should be 1
6060
}
6161
}
6262

@@ -88,18 +88,18 @@ try
8888
$issueCounts = $issueCounts | Sort-Object -Property Count -Descending
8989

9090
It 'Should return expected number of issues for each repository' {
91-
@($issueCounts[0].Count) | Should be 3
92-
@($issueCounts[1].Count) | Should be 0
91+
$issueCounts[0].Count | Should be 3
92+
$issueCounts[1].Count | Should be 0
9393
}
9494

9595
It 'Should return expected repository names' {
96-
@($issueCounts[0].Uri) | Should be ($repo1.svn_url)
97-
@($issueCounts[1].Uri) | Should be ($repo2.svn_url)
96+
$issueCounts[0].Uri | Should be $repo1.svn_url
97+
$issueCounts[1].Uri | Should be $repo2.svn_url
9898
}
9999
}
100100

101-
$null = Remove-GitHubRepository -Uri ($repo1.svn_url)
102-
$null = Remove-GitHubRepository -Uri ($repo2.svn_url)
101+
$null = Remove-GitHubRepository -Uri $repo1.svn_url
102+
$null = Remove-GitHubRepository -Uri $repo2.svn_url
103103
}
104104

105105

@@ -186,10 +186,10 @@ try
186186
$null = New-GitHubRepository -RepositoryName $repositoryName -AutoInit
187187
$repositoryUrl = "https://github.com/$script:ownerName/$repositoryName"
188188

189-
$collaborators = Get-GitHubRepositoryCollaborator -Uri $repositoryUrl
189+
$collaborators = @(Get-GitHubRepositoryCollaborator -Uri $repositoryUrl)
190190

191191
It 'Should return expected number of collaborators' {
192-
@($collaborators).Count | Should be 1
192+
$collaborators.Count | Should be 1
193193
}
194194

195195
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
@@ -201,10 +201,10 @@ try
201201
$null = New-GitHubRepository -RepositoryName $repositoryName -AutoInit
202202
$repositoryUrl = "https://github.com/$script:ownerName/$repositoryName"
203203

204-
$contributors = Get-GitHubRepositoryContributor -Uri $repositoryUrl -IncludeStatistics
204+
$contributors = @(Get-GitHubRepositoryContributor -Uri $repositoryUrl -IncludeStatistics)
205205

206206
It 'Should return expected number of contributors' {
207-
@($contributors).Count | Should be 1
207+
$contributors.Count | Should be 1
208208
}
209209

210210
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
@@ -242,15 +242,13 @@ try
242242
}
243243

244244
Describe 'Getting repositories from organization' {
245-
<# Temporary hack due to issues with this test in ADO #> . (Join-Path -Path $moduleRootPath -ChildPath 'Tests\Config\Settings.ps1')
246-
247-
$original = Get-GitHubRepository -OrganizationName $script:organizationName
245+
$original = @(Get-GitHubRepository -OrganizationName $script:organizationName)
248246

249247
$repo = New-GitHubRepository -RepositoryName ([guid]::NewGuid().Guid) -OrganizationName $script:organizationName
250-
$current = Get-GitHubRepository -OrganizationName $script:organizationName
248+
$current = @(Get-GitHubRepository -OrganizationName $script:organizationName)
251249

252250
It 'Should return expected number of organization repositories' {
253-
(@($current).Count - @($original).Count) | Should be 1
251+
($current.Count - $original.Count) | Should be 1
254252
}
255253

256254
$null = Remove-GitHubRepository -Uri $repo.svn_url
@@ -260,15 +258,15 @@ try
260258
$repositoryName = [guid]::NewGuid().Guid
261259
$null = New-GitHubRepository -RepositoryName $repositoryName -AutoInit
262260

263-
$contributors = Get-GitHubRepositoryContributor -OwnerName $script:ownerName -RepositoryName $repositoryName -IncludeStatistics
261+
$contributors = @(Get-GitHubRepositoryContributor -OwnerName $script:ownerName -RepositoryName $repositoryName -IncludeStatistics)
264262

265263
$uniqueContributors = $contributors |
266264
Select-Object -ExpandProperty author |
267265
Select-Object -ExpandProperty login -Unique
268266
Sort-Object
269267

270268
It 'Should return expected number of unique contributors' {
271-
@($uniqueContributors).Count | Should be 1
269+
$uniqueContributors.Count | Should be 1
272270
}
273271

274272
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName
@@ -298,14 +296,14 @@ try
298296
$repositoryName = [guid]::NewGuid().Guid
299297
$null = New-GitHubRepository -RepositoryName $repositoryName -AutoInit
300298

301-
$branches = Get-GitHubRepositoryBranch -OwnerName $script:ownerName -RepositoryName $repositoryName
299+
$branches = @(Get-GitHubRepositoryBranch -OwnerName $script:ownerName -RepositoryName $repositoryName)
302300

303301
It 'Should return expected number of repository branches' {
304-
@($branches).Count | Should be 1
302+
$branches.Count | Should be 1
305303
}
306304

307305
It 'Should return the name of the branches' {
308-
@($branches[0].name) | Should be "master"
306+
$branches[0].name | Should be 'master'
309307
}
310308

311309
$null = Remove-GitHubRepository -OwnerName $script:ownerName -RepositoryName $repositoryName

Tests/GitHubAssignees.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ try
4444
Context 'For adding an assignee to an issue'{
4545
$assigneeList = @(Get-GitHubAssignee -Uri $repo.svn_url)
4646
$assigneeUserName = $assigneeList[0].login
47-
$assignees = @($assigneeUserName)
47+
$assignees = $assigneeUserName
4848
New-GithubAssignee -Uri $repo.svn_url -Issue $issue.number -Assignee $assignees
4949
$issue = Get-GitHubIssue -Uri $repo.svn_url -Issue $issue.number
5050

0 commit comments

Comments
 (0)