Skip to content

Commit

Permalink
Allow referencing GitHub issues by GH- prefix (#96)
Browse files Browse the repository at this point in the history
Co-authored-by: Emil Masiakowski <emil.masiakowski@amsterdamstandard.com>
  • Loading branch information
EmilMassey and Emil Masiakowski authored May 24, 2024
1 parent 2633f17 commit 774f707
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ see examples of different comment variants which are supported:

// TODO: APP-123 fix it when this Jira ticket is closed
// TODO: #123 fix it when this GitHub issue is closed
// TODO: GH-123 fix it when this GitHub issue is closed
// TODO: some-organization/some-repo#123 change me if this GitHub pull request is closed
```

Expand Down Expand Up @@ -314,6 +315,7 @@ There are multiple ways to reference GitHub issue/PR:
##### Only number
```php
// TODO: #123 - fix me
// TODO: GH-123 - fix me
```
If the `defaultOwner` is set to `acme` and `defaultRepo` is set to `hello-world`, the referenced issue is resolved to `acme/hello-world#123`.

Expand Down
2 changes: 1 addition & 1 deletion src/utils/ticket/GitHubTicketStatusFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class GitHubTicketStatusFetcher implements TicketStatusFetcher
private const KEY_REGEX = '
((?P<githubOwner>[\w\-\.]+)\/)? # optional owner with slash separator
(?P<githubRepo>[\w\-\.]+)? # optional repo
\#(?P<githubNumber>\d+) # ticket number
(\#|GH-)(?P<githubNumber>\d+) # ticket number
';

private string $defaultOwner;
Expand Down
11 changes: 9 additions & 2 deletions tests-e2e/github/expected-errors.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"totals": {
"errors": 0,
"file_errors": 4
"file_errors": 5
},
"files": {
"src/github-issues-and-prs.php": {
"errors": 4,
"errors": 5,
"messages": [
{
"message": "Should have been resolved in #59: fix me.",
Expand Down Expand Up @@ -34,6 +34,13 @@
"ignorable": false,
"tip": "See https://github.com/staabm/phpstan-todo-by/issues/26",
"identifier": "todoBy.ticket"
},
{
"message": "Comment should have been resolved in GH-27.",
"line": 7,
"ignorable": false,
"tip": "See https://github.com/staabm/phpstan-todo-by/issues/27",
"identifier": "todoBy.ticket"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions tests-e2e/github/src/github-issues-and-prs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
// TODO: staabm/phpstan-dba#452 - change me after https://github.com/staabm/phpstan-dba/issues/452 is closed
// TODO: phpstan/phpstan#3
// TODO: #26 - needs https://github.com/staabm/phpstan-todo-by/pull/26
// TODO: GH-27

0 comments on commit 774f707

Please sign in to comment.