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