-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from mozilla-services/parse-prs-from-release-n…
…otes Parse PRs from Release notes 🚀
- Loading branch information
Showing
11 changed files
with
169 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
name,tagName,isDraft,isLatest,isPrerelease,description,createdAt,publishedAt | ||
20.1.0,20.1.0,false,true,false,Description for 20.1.0,2020-05-04T14:55:36Z,2020-05-04T15:02:21Z | ||
0.2.0,0.2.0,false,false,false,Description for 0.2.0,2019-12-15T17:35:58Z,2019-12-15T20:00:44Z | ||
0.1.0,0.1.0,false,false,false,Description for 0.1.0,2018-07-13T15:23:49Z,2018-07-16T13:30:36Z | ||
0.2.0,0.2.0,false,false,false,"## What's Changed | ||
* Develop feature by @hackebrot in https://github.com/hackebrot/turtle/pull/123 | ||
* Add tests for feature by @hackebrot in https://github.com/hackebrot/turtle/pull/124 | ||
",2019-12-15T17:35:58Z,2019-12-15T20:00:44Z | ||
0.1.0,0.1.0,false,false,false,"## What's Changed | ||
* Create app by @hackebrot in https://github.com/hackebrot/turtle/pull/22 | ||
",2018-07-13T15:23:49Z,2018-07-16T13:30:36Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name,tagName,isDraft,isLatest,isPrerelease,description,createdAt,publishedAt,prs | ||
20.1.0,20.1.0,false,true,false,Description for 20.1.0,2020-05-04T14:55:36Z,2020-05-04T15:02:21Z,null | ||
0.2.0,0.2.0,false,false,false,"## What's Changed | ||
* Develop feature by @hackebrot in https://github.com/hackebrot/turtle/pull/123 | ||
* Add tests for feature by @hackebrot in https://github.com/hackebrot/turtle/pull/124 | ||
",2019-12-15T17:35:58Z,2019-12-15T20:00:44Z,"[123,124]" | ||
0.1.0,0.1.0,false,false,false,"## What's Changed | ||
* Create app by @hackebrot in https://github.com/hackebrot/turtle/pull/22 | ||
",2018-07-13T15:23:49Z,2018-07-16T13:30:36Z,[22] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[ | ||
{ | ||
"Name": "20.1.0", | ||
"TagName": "20.1.0", | ||
"IsDraft": false, | ||
"IsLatest": true, | ||
"IsPrerelease": false, | ||
"Description": "Description for 20.1.0", | ||
"CreatedAt": "2020-05-04T14:55:36Z", | ||
"PublishedAt": "2020-05-04T15:02:21Z", | ||
"PRs": null | ||
}, | ||
{ | ||
"Name": "0.2.0", | ||
"TagName": "0.2.0", | ||
"IsDraft": false, | ||
"IsLatest": false, | ||
"IsPrerelease": false, | ||
"Description": "## What's Changed\n* Develop feature by @hackebrot in https://github.com/hackebrot/turtle/pull/123\n* Add tests for feature by @hackebrot in https://github.com/hackebrot/turtle/pull/124\n", | ||
"CreatedAt": "2019-12-15T17:35:58Z", | ||
"PublishedAt": "2019-12-15T20:00:44Z", | ||
"PRs": [ | ||
123, | ||
124 | ||
] | ||
}, | ||
{ | ||
"Name": "0.1.0", | ||
"TagName": "0.1.0", | ||
"IsDraft": false, | ||
"IsLatest": false, | ||
"IsPrerelease": false, | ||
"Description": "## What's Changed\n* Create app by @hackebrot in https://github.com/hackebrot/turtle/pull/22\n", | ||
"CreatedAt": "2018-07-13T15:23:49Z", | ||
"PublishedAt": "2018-07-16T13:30:36Z", | ||
"PRs": [ | ||
22 | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package github | ||
|
||
import ( | ||
"regexp" | ||
"strconv" | ||
) | ||
|
||
// ReleaseWithPRs embeds a GitHub GraphQL API Release object with an added slice | ||
// of PR numbers, which we have parsed from its auto-generated release notes. | ||
type ReleaseWithPRs struct { | ||
Release | ||
PRs []int | ||
} | ||
|
||
// NewReleaseWithPrs creates a new ReleaseWithPRs by parsing PR numbers from | ||
// auto-generated Release Descriptions. | ||
func NewReleaseWithPRs(r *Release) *ReleaseWithPRs { | ||
var prs []int | ||
|
||
// Pattern for auto-generated release notes. For more information see: | ||
// https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes | ||
re := regexp.MustCompile(`\* .*by @\w+ in .+\/pull\/(?P<pr>\d+)`) | ||
|
||
for _, match := range re.FindAllStringSubmatch(r.Description, -1) { | ||
for i, name := range re.SubexpNames() { | ||
if name == "pr" { | ||
n, err := strconv.Atoi(match[i]) | ||
if err != nil { | ||
continue | ||
} | ||
prs = append(prs, n) | ||
} | ||
} | ||
} | ||
|
||
return &ReleaseWithPRs{*r, prs} | ||
} |