-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathGet-GitHubPullRequestByNumber.ps1
More file actions
65 lines (53 loc) · 1.87 KB
/
Get-GitHubPullRequestByNumber.ps1
File metadata and controls
65 lines (53 loc) · 1.87 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
filter Get-GitHubPullRequestByNumber {
<#
.SYNOPSIS
Get a pull request by number.
.DESCRIPTION
Gets a specific pull request in a repository by its pull request number.
Anyone with read access to the repository can use this endpoint.
.EXAMPLE
```powershell
Get-GitHubPullRequestByNumber -Owner 'octocat' -Repository 'Hello-World' -Number 1
```
Gets pull request #1 from the repository.
.OUTPUTS
GitHubPullRequest
.NOTES
[Get a pull request](https://docs.github.com/rest/pulls/pulls#get-a-pull-request)
#>
[OutputType([GitHubPullRequest])]
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains a long link.')]
param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Owner,
# The name of the repository. The name is not case sensitive.
[Parameter(Mandatory)]
[string] $Repository,
# The number that identifies the pull request.
[Parameter(Mandatory)]
[int] $Number,
# The context to run the command in. Used to get the details for the API call.
[Parameter(Mandatory)]
[object] $Context
)
begin {
$stackPath = Get-PSCallStackPath
Write-Debug "[$stackPath] - Start"
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
$apiParams = @{
Method = 'GET'
APIEndpoint = "/repos/$Owner/$Repository/pulls/$Number"
Context = $Context
}
Invoke-GitHubAPI @apiParams | ForEach-Object {
[GitHubPullRequest]::new($_.Response, $Owner, $Repository)
}
}
end {
Write-Debug "[$stackPath] - End"
}
}