Skip to content

Commit d06c417

Browse files
authored
Add github action to pre-triage new issues (#2117)
Add a GitHub Action to pre-triage new issue -- close the issues that are duplicate of #1306 and #1315
1 parent 439bd25 commit d06c417

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/IssuePreTriage.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Issue Pre-triage
2+
3+
on:
4+
schedule:
5+
# At 13:00 UTC every day.
6+
- cron: '0 13 * * *'
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
defaults:
11+
run:
12+
shell: pwsh
13+
14+
env:
15+
POWERSHELL_TELEMETRY_OPTOUT: 1
16+
17+
jobs:
18+
process-new-issues:
19+
name: Process new issues
20+
timeout-minutes: 20
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v2
25+
26+
- name: do-work
27+
run: |
28+
$env:GITHUB_TOKEN = ${{ secrets.GITHUB_TOKEN }}
29+
./tools/issue-mgmt/CloseDupIssues.ps1

tools/issue-mgmt/CloseDupIssues.ps1

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## Close issues that are duplicate to #1306 and #1315
2+
3+
class issue
4+
{
5+
[string] $number
6+
[string] $title
7+
[string] $author
8+
[string] $body
9+
}
10+
11+
$repo_name = "PowerShell/PSReadLine"
12+
$root_url = "https://github.com/PowerShell/PSReadLine/issues"
13+
$msg_upgrade = @"
14+
Please upgrade to the [2.1.0 version of PSReadLine](https://www.powershellgallery.com/packages/PSReadLine/2.1.0) from PowerShell Gallery.
15+
See the [upgrading section](https://github.com/PowerShell/PSReadLine#upgrading) for instructions. Please let us know if you run into the same issue with the latest version.
16+
"@
17+
18+
$issue_list = gh issue list -l 'Needs-Triage :mag:' -R $repo_name
19+
$issue_numbers = $issue_list | Where-Object { $_ -notlike '*Issue-Enhancement,*' } | ForEach-Object { $_.Split('OPEN', [System.StringSplitOptions]::TrimEntries)[0] }
20+
21+
$issues = @()
22+
foreach ($number in $issue_numbers)
23+
{
24+
$issue_detail = gh issue view $number -R $repo_name
25+
26+
$new_issue = [issue]::new()
27+
$new_issue.number = $number
28+
$new_issue.title = $issue_detail[0].Split('title:', [System.StringSplitOptions]::TrimEntries)[1]
29+
$new_issue.author = $issue_detail[2].Split('author:', [System.StringSplitOptions]::TrimEntries)[1]
30+
$new_issue.body = $issue_detail[9..$issue_detail.Length] -join "`n"
31+
32+
$issues += $new_issue
33+
}
34+
35+
foreach ($item in $issues)
36+
{
37+
$comment = $null
38+
$number = $item.number
39+
$title = $item.title
40+
$body = $item.body
41+
$author = $item.author
42+
43+
Write-Host "Issue: $root_url/$number" -ForegroundColor Green
44+
45+
if ($title.Contains('https://github.com/PowerShell/PSReadLine/issues/new') -or
46+
$body.Contains('https://github.com/PowerShell/PSReadLine/issues/new') -or
47+
$body -match 'PSReadLine: 2\.\d\.\d(-\w+)?' -or
48+
$body -match 'PSReadline version: 2\.\d\.\d(-\w+)?' -or
49+
$body -match 'PowerShell: 7\.\d\.\d' -or
50+
$body -match 'PS version: 7\.\d\.\d')
51+
{
52+
## The issue reported a recent version of PSReadLine, so leave it as is.
53+
continue
54+
}
55+
56+
if ($body.Contains('System.ArgumentOutOfRangeException:') -and
57+
$body.Contains('System.Console.SetCursorPosition(') -and
58+
$body.Contains('Microsoft.PowerShell.PSConsoleReadLine.ReallyRender('))
59+
{
60+
## The issue either reported an old version of PSReadLine, or provided no
61+
## information about the version. In either case, it's likely a duplicate
62+
## of #1306 and can be closed.
63+
$comment = 'This issue was already fixed (see #1306). {0}' -f $msg_upgrade
64+
}
65+
elseif ($body.Contains('Ctrl+l') -and
66+
$body.Contains('System.IO.IOException:') -and
67+
$body.Contains('Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(') -and
68+
$body.Contains('System.IO.__Error.WinIOError('))
69+
{
70+
## The issue either reported an old version of PSReadLine, or provided no
71+
## information about the version. In either case, it's likely a duplicate
72+
## of #1315 and can be closed.
73+
$comment = 'This issue was already fixed (see #1315). {0}' -f $msg_upgrade
74+
}
75+
elseif ($title.Contains('https://github.com/lzybkr/PSReadLine/issues/new') -or
76+
$body.Contains('https://github.com/lzybkr/PSReadLine/issues/new') -or
77+
$body -match 'PSReadLine: 2.0.0-\w+\d' -or
78+
$body -match 'PSReadline version: 2.0.0-\w+\d')
79+
{
80+
## The issue reported an old version of PSReadLine. Even though the issue
81+
## may not be a duplicate of either #1306 or #1315, we will close it and
82+
## ask the author to use the latest stable version.
83+
$comment = "@$author, you were using a pretty old version of PSReadLine (2.0.0-beta2 or prior), and it's likely that the issue was fixed in a newer version.`n{0}" -f $msg_upgrade
84+
}
85+
86+
if ($comment)
87+
{
88+
## Comment the issue and then close it.
89+
$null = gh api "/repos/$repo_name/issues/$number/comments" --raw-field body=$comment &&
90+
gh issue close $number -R $repo_name
91+
}
92+
}

0 commit comments

Comments
 (0)