]> apps.delaporte.us Git - dotfiles.git/blob - psmodules/edgithub.psm1
f24fcfa87619227226a0dcf2fde8ef372660ee80
[dotfiles.git] / psmodules / edgithub.psm1
1 <#
2 .SYNPOSIS
3
4 Fetch closed GitHub issues that were updated in the last 14 days.
5
6 .NOTES
7
8 Thism modules requires the following in your PowerShell profile:
9 $env:GITHUB_USERNAME = 'github_username'
10 $env:GITHUB_ORG = 'github_organization_name'
11 $env:GITHUB_REPOS = @('repository1', 'repository2', 'repository3')
12
13 #>
14 function Get-GHClosed {
15 param(
16 [int]$days = -14
17 )
18 $repos = $env:GITHUB_REPOS.split(" ")
19 $issueSearchParams = @{ State = 'closed'; OwnerName = $env:GITHUB_ORG }
20 $closed = @()
21 $repos | ForEach-Object {
22 $closed += Get-GitHubIssue -RepositoryName $_ @issueSearchParams
23 }
24
25 # Limit to past two weeks
26 $issues = $closed | Where-Object { $_.updated_at -gt (Get-Date).AddDays($days) }
27 return $issues
28 }
29
30
31 <#
32 .SYNPOSIS
33
34 Fetch GitHub issues that are tagged to discuss this morning.
35
36 #>
37 function Get-GHToDiscuss {
38 param(
39 [int]$days = -14
40 )
41 $repos = $env:GITHUB_REPOS.split(" ")
42 $issueSearchParams = @{ State = 'open'; OwnerName = $env:GITHUB_ORG }
43 $closed = @()
44 $repos | ForEach-Object {
45 $closed += Get-GitHubIssue -RepositoryName $_ @issueSearchParams
46 }
47 $issues = $issues | Where-Object { $_.labels -Contains 'DiscussAtStandUp' }
48
49 return $issues
50 }
51
52
53 <#
54 .SYNOPSIS
55
56 Show closed GitHub issues that were updated in the last 14 days.
57
58 #>
59 function Show-GHClosed() {
60 param(
61 [int]$days = -14
62 )
63 Get-GHClosed -days $days | ForEach-Object {
64 # Markdown output
65 " + [" + $_.Title + " (" + $_.Number + ")](" + $_.html_url + ")"
66 }
67 # Format-Table -Property Number, Title, Url
68
69 }
70
71 <#
72 .SYNPOSIS
73
74 Fetch GitHub issues I am working on.
75
76 #>
77 function Get-GHMine() {
78 $repos = $env:GITHUB_REPOS.split(" ")
79 $issueSearchParams = @{ Assignee = $env:GITHUB_USERNAME;
80 State = 'open'; OwnerName = $env:GITHUB_ORG }
81 $issues = @()
82 $repos | ForEach-Object {
83 $issues += Get-GitHubIssue -RepositoryName $_ @issueSearchParams
84 }
85
86 # Ignore issues that have been updated in the last day.
87 $issues = $issues | Where-Object { $_.updated_at -lt (Get-Date).AddDays(-1) }
88
89 return $issues
90 }
91
92 <#
93 .SYNOPSIS
94
95 Show GitHub issues I am working on.
96
97 #>
98 function Show-GHMine() {
99 Get-GHMine | ForEach-Object {
100 # Markdown output
101 " + [" + $_.Title + " (" + $_.Number + ")](" + $_.html_url + ")"
102 }
103 }
104
105 <#
106 .SYNOPSIS
107
108 Get GitHub issues that need sized.
109
110 .DESCRIPTION
111
112 Runs this GitHub search:
113 is:open is:issue -label:M -label:L -label:S -label:XL -label:XS
114
115 #>
116 function Get-GHUnsized() {
117 $repos = $env:GITHUB_REPOS.split(" ")
118 $issueSearchParams = @{ State = 'open'; OwnerName = 'techservicesillinois' }
119 $issues = @()
120 $repos | ForEach-Object {
121 $issues += Get-GitHubIssue -RepositoryName $_ @issueSearchParams
122 }
123
124 # Ignore issues that have been updated in the last day.
125 $issues = $issues | Where-Object { -Not $_.labels -Contains 'XS' }
126 $issues = $issues | Where-Object { -Not $_.labels -Contains 'S' }
127 $issues = $issues | Where-Object { -Not $_.labels -Contains 'M' }
128 $issues = $issues | Where-Object { -Not $_.labels -Contains 'L' }
129 # Leave XL issues, as they need split.
130
131 return $issues
132 }
133
134 function Get-GHNoMilestone() {
135 param(
136 [string]$repository
137 )
138 $repos = $env:GITHUB_REPOS.split(" ")
139 if($repository){
140 $repos = @($repository)
141 }
142 $issueSearchParams = @{ State = 'open'; OwnerName = 'techservicesillinois' }
143 $issues = @()
144 $repos | ForEach-Object {
145 $issues += Get-GitHubIssue -RepositoryName $_ @issueSearchParams
146 }
147
148 # Get open issues with empty milestone
149 $issues = $issues | Where-Object { $null -eq $_.milestone }
150 return $issues
151 }
152 function Show-GHNoMilestone(){
153 param(
154 [string]$repository
155 )
156 Get-GHNoMilestone -Repository $repository | Show-GHIssuesAsMarkdown
157 }
158
159 function Show-GHUnsized() {
160 Get-GHUnsized | ForEach-Object {
161 # Markdown output
162 " + [" + $_.Title + " (" + $_.Number + ")](" + $_.html_url + ")" + $_.labels
163 }
164 }
165
166 function Show-GHByAssignee() {
167 $repos = $env:GITHUB_REPOS.split(" ")
168 $issueSearchParams = @{ State = 'open'; OwnerName = 'techservicesillinois' }
169 $issues = @()
170 $repos | ForEach-Object {
171 $issues += Get-GitHubIssue -RepositoryName $_ @issueSearchParams
172 }
173
174 # TODO: Group output by assignee.
175
176 return $issues
177 }
178
179
180
181 function Show-GHToDiscuss() {
182 Get-GHToDiscuss | Show-GHIssuesAsMarkdown
183 }
184
185
186 function Show-GHIssuesAsMarkdown() {
187 process
188 {
189 # Markdown output
190 " + [" + $_.Title + " (" + $_.Number + ")](" + $_.html_url + ")"
191 }
192 }
193
194
195 Export-ModuleMember -Function Get-GHClosed
196 Export-ModuleMember -Function Show-GHClosed
197 Export-ModuleMember -Function Get-GHMine
198 Export-ModuleMember -Function Show-GHMine
199 Export-ModuleMember -Function Get-GHUnsized
200 Export-ModuleMember -Function Show-GHUnsized
201 Export-ModuleMember -Function Show-GHToDiscuss
202 Export-ModuleMember -Function Get-GHNoMilestone
203 Export-ModuleMember -Function Show-GHNoMilestone