Skip to content

Commit aa045ce

Browse files
authored
fix(go): Update scope matching and regen regex (googleapis#520)
The scope matching was too greedy and caught things like "pubsublite". Scope should be an exact match or be within the same directory structure. The regen PR regex did not account for commit that had a body portion of a commit.
1 parent eaa8582 commit aa045ce

3 files changed

Lines changed: 64 additions & 9 deletions

File tree

__snapshots__/yoshi-go.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ exports['CHANGES-go-yoshi'] = `
1212
1313
* **all:** auto-regenerate gapics ([#1000](https://www.github.com/googleapis/yoshi-go-test-repo/issues/1000)) ([#1001](https://www.github.com/googleapis/yoshi-go-test-repo/issues/1001))
1414
* **asset:** added a really cool feature ([d7d1c89](https://www.github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))
15+
* **pubsublite:** start generating v1 ([1d9662c](https://www.github.com/googleapis/yoshi-go-test-repo/commit/1d9662cf08ab1cf3b68d95dee4dc99b7c4aac371))
1516
1617
1718
### Bug Fixes
@@ -21,14 +22,14 @@ exports['CHANGES-go-yoshi'] = `
2122
`
2223

2324
exports['PR body-go-yoshi'] = {
24-
'title': 'chore: release 0.124.0',
25-
'body': ':robot: I have created a release \\*beep\\* \\*boop\\* \n---\n## [0.124.0](https://www.github.com/googleapis/yoshi-go-test-repo/compare/v0.123.4...v0.124.0) \n\n\n### Features\n\n* **all:** auto-regenerate gapics ([#1000](https://www.github.com/googleapis/yoshi-go-test-repo/issues/1000)) ([#1001](https://www.github.com/googleapis/yoshi-go-test-repo/issues/1001))\n* **asset:** added a really cool feature ([d7d1c89](https://www.github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))\n\n\n### Bug Fixes\n\n* **automl:** fixed a really bad bug ([d7d1c89](https://www.github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please).',
26-
'head': 'release-v0.124.0',
27-
'base': 'master'
25+
"title": "chore: release 0.124.0",
26+
"body": ":robot: I have created a release \\*beep\\* \\*boop\\* \n---\n## [0.124.0](https://www.github.com/googleapis/yoshi-go-test-repo/compare/v0.123.4...v0.124.0) \n\n\n### Features\n\n* **all:** auto-regenerate gapics ([#1000](https://www.github.com/googleapis/yoshi-go-test-repo/issues/1000)) ([#1001](https://www.github.com/googleapis/yoshi-go-test-repo/issues/1001))\n* **asset:** added a really cool feature ([d7d1c89](https://www.github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))\n* **pubsublite:** start generating v1 ([1d9662c](https://www.github.com/googleapis/yoshi-go-test-repo/commit/1d9662cf08ab1cf3b68d95dee4dc99b7c4aac371))\n\n\n### Bug Fixes\n\n* **automl:** fixed a really bad bug ([d7d1c89](https://www.github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please).",
27+
"head": "release-v0.124.0",
28+
"base": "master"
2829
}
2930

3031
exports['labels-go-yoshi'] = {
31-
'labels': [
32-
'autorelease: pending'
32+
"labels": [
33+
"autorelease: pending"
3334
]
3435
}

src/releasers/go-yoshi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class GoYoshi extends ReleasePR {
6363
// Skipping commits related to sub-modules as they are not apart of the
6464
// parent module.
6565
for (const subModule of SUB_MODULES) {
66-
if (scope.startsWith(subModule)) {
66+
if (scope === subModule || scope.startsWith(subModule + '/')) {
6767
// TODO(codyoss): eventually gather these commits into a map so we can
6868
// purpose releases for sub-modules.
6969
return false;
@@ -73,7 +73,7 @@ export class GoYoshi extends ReleasePR {
7373
// If there are more than one of these commits, append associated PR.
7474
if (GAPIC_PR_REGEX.test(commit.message)) {
7575
if (gapicPR) {
76-
const issueRe = /.*(?<pr>\(.*\))$/;
76+
const issueRe = /.*(?<pr>\(.*\))/;
7777
const match = commit.message.match(issueRe);
7878
if (match?.groups?.pr) {
7979
gapicPR.message = `${gapicPR.message} ${match.groups.pr}`;

test/releasers/fixtures/yoshi-go/commits.json

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,33 @@
8585
}
8686
}
8787
},
88+
{
89+
"node": {
90+
"message": "fix(pubsub/pstest): this commit should be ignored",
91+
"oid": "dad2c890dc1526f4d62ceedad581f498195c8939",
92+
"associatedPullRequests": {
93+
"edges": [
94+
{
95+
"node": {
96+
"mergeCommit": {
97+
"oid": "dad2c890dc1526f4d62ceedad581f498195c8939"
98+
},
99+
"number": 293,
100+
"labels": {
101+
"edges": [
102+
{
103+
"node": {
104+
"name": "cla: yes"
105+
}
106+
}
107+
]
108+
}
109+
}
110+
}
111+
]
112+
}
113+
}
114+
},
88115
{
89116
"node": {
90117
"message": "fix: this commit should be ignored",
@@ -141,7 +168,7 @@
141168
},
142169
{
143170
"node": {
144-
"message": "feat(all): auto-regenerate gapics (#1001)",
171+
"message": "feat(all): auto-regenerate gapics (#1001)\n\nCommit Body",
145172
"oid": "1f9663cf08ab1cf3b68d95dee4dc99b7c4aac371",
146173
"associatedPullRequests": {
147174
"edges": [
@@ -165,6 +192,33 @@
165192
]
166193
}
167194
}
195+
},
196+
{
197+
"node": {
198+
"message": "feat(pubsublite): start generating v1",
199+
"oid": "1d9662cf08ab1cf3b68d95dee4dc99b7c4aac371",
200+
"associatedPullRequests": {
201+
"edges": [
202+
{
203+
"node": {
204+
"mergeCommit": {
205+
"oid": "1d9662cf08ab1cf3b68d95dee4dc99b7c4aac371"
206+
},
207+
"number": 301,
208+
"labels": {
209+
"edges": [
210+
{
211+
"node": {
212+
"name": "cla: yes"
213+
}
214+
}
215+
]
216+
}
217+
}
218+
}
219+
]
220+
}
221+
}
168222
}
169223
],
170224
"pageInfo": {

0 commit comments

Comments
 (0)