Skip to content

Commit 4a635d2

Browse files
fix: update release script to consider only PRs with base.ref "main" (#398)
1 parent 0dd28fa commit 4a635d2

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

tools/release/lib/release.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ def get_sorted_merged_pulls(
3939
pull
4040
for pull in pulls
4141
if pull.merged
42-
and not pull.title.startswith("chore: release")
43-
and not pull.user.login.startswith("github-actions")
42+
and pull.base.ref == "main"
43+
and not pull.title.startswith("chore: release")
44+
and not pull.user.login.startswith("github-actions")
4445
),
4546
key=lambda pull: pull.merged_at,
4647
)
@@ -50,9 +51,10 @@ def get_sorted_merged_pulls(
5051
pull
5152
for pull in pulls
5253
if pull.merged
53-
and (pull.merged_at > last_release.created_at)
54-
and not pull.title.startswith("chore: release")
55-
and not pull.user.login.startswith("github-actions")
54+
and pull.base.ref == "main"
55+
and (pull.merged_at > last_release.created_at)
56+
and not pull.title.startswith("chore: release")
57+
and not pull.user.login.startswith("github-actions")
5658
),
5759
key=lambda pull: pull.merged_at,
5860
)
@@ -127,7 +129,7 @@ def multiple_contributors_mention_md(contributors: List[str]) -> str:
127129
contrib_by = (
128130
contrib_by[:last_comma].strip()
129131
+ " and "
130-
+ contrib_by[last_comma + 1:].strip()
132+
+ contrib_by[last_comma + 1 :].strip()
131133
)
132134
return contrib_by
133135

tools/release/lib/tests/test_release.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
User = namedtuple("User", ["login"])
77
Commit = namedtuple("Commit", ["author", "commit"])
88
CommitMessage = namedtuple("CommitMessage", ["message"])
9+
PullRequestBase = namedtuple("PullRequestBase", "ref")
910
PullRequestTuple = namedtuple(
1011
"PullRequest",
11-
["title", "number", "state", "merged", "merged_at", "user", "commits"],
12+
["title", "number", "state", "base", "merged", "merged_at", "user", "commits"],
1213
)
1314

1415

@@ -41,6 +42,7 @@ def get_pulls(state="closed"):
4142
number=1,
4243
state="open",
4344
merged=False,
45+
base=PullRequestBase("main"),
4446
merged_at=datetime(2023, 2, 2),
4547
user=User("contributor_1"),
4648
commits=[
@@ -68,6 +70,7 @@ def get_pulls(state="closed"):
6870
state="closed",
6971
merged=True,
7072
merged_at=datetime(2023, 2, 1),
73+
base=PullRequestBase("main"),
7174
user=User("contributor_2"),
7275
commits=[
7376
Commit(
@@ -106,6 +109,7 @@ def get_pulls(state="closed"):
106109
state="closed",
107110
merged=True,
108111
merged_at=datetime(2023, 2, 2),
112+
base=PullRequestBase("main"),
109113
user=User("contributor_3"),
110114
commits=[
111115
Commit(
@@ -132,6 +136,7 @@ def get_pulls(state="closed"):
132136
state="closed",
133137
merged=True,
134138
merged_at=datetime(2023, 2, 3),
139+
base=PullRequestBase("main"),
135140
user=User("contributor_4"),
136141
commits=[
137142
Commit(
@@ -158,6 +163,7 @@ def get_pulls(state="closed"):
158163
state="closed",
159164
merged=False,
160165
merged_at=datetime(2023, 2, 4),
166+
base=PullRequestBase("main"),
161167
user=User("contributor_3"),
162168
commits=[
163169
Commit(
@@ -184,6 +190,7 @@ def get_pulls(state="closed"):
184190
state="closed",
185191
merged=True,
186192
merged_at=datetime(2023, 2, 5),
193+
base=PullRequestBase("main"),
187194
user=User("contributor_2"),
188195
commits=[
189196
Commit(
@@ -210,6 +217,7 @@ def get_pulls(state="closed"):
210217
state="closed",
211218
merged=True,
212219
merged_at=datetime(2023, 5, 2),
220+
base=PullRequestBase("main"),
213221
user=User("new_contributor_2"),
214222
commits=[
215223
Commit(
@@ -242,6 +250,7 @@ def get_pulls(state="closed"):
242250
state="closed",
243251
merged=True,
244252
merged_at=datetime(2023, 5, 5),
253+
base=PullRequestBase("main"),
245254
user=User("contributor_3"),
246255
commits=[
247256
Commit(
@@ -274,6 +283,7 @@ def get_pulls(state="closed"):
274283
state="closed",
275284
merged=True,
276285
merged_at=datetime(2023, 5, 1),
286+
base=PullRequestBase("main"),
277287
user=User("new_contributor_1"),
278288
commits=[
279289
Commit(
@@ -312,6 +322,7 @@ def get_pulls(state="closed"):
312322
state="closed",
313323
merged=True,
314324
merged_at=datetime(2023, 5, 10),
325+
base=PullRequestBase("another_branch"),
315326
user=User("new_contributor_1"),
316327
commits=[
317328
Commit(
@@ -330,6 +341,7 @@ def get_pulls(state="closed"):
330341
state="closed",
331342
merged=True,
332343
merged_at=datetime(2023, 5, 9),
344+
base=PullRequestBase("main"),
333345
user=User("new_contributor_1"),
334346
commits=[
335347
Commit(
@@ -359,8 +371,9 @@ def test_get_sorted_merged_pulls():
359371
pull
360372
for pull in pulls
361373
if pull.merged
362-
and not pull.title.startswith("chore: release")
363-
and not pull.user.login.startswith("github-actions")
374+
and pull.base.ref == "main"
375+
and not pull.title.startswith("chore: release")
376+
and not pull.user.login.startswith("github-actions")
364377
],
365378
key=lambda pull: pull.merged_at,
366379
)
@@ -428,7 +441,6 @@ def test_whats_changed_md():
428441
"* Feature 8 by @new_contributor_1, @new_contributor_coauthor3 and @new_contributor_coauthor4 in https://github.com/ada-url/ada/pull/15",
429442
"* Feature 9 by @new_contributor_2 and @new_contributor_coauthor1 in https://github.com/ada-url/ada/pull/13",
430443
"* Feature 7 by @contributor_3 and @new_contributor_coauthor2 in https://github.com/ada-url/ada/pull/14",
431-
"* Feature 11 by @new_contributor_1 in https://github.com/ada-url/ada/pull/16",
432444
]
433445

434446

@@ -479,7 +491,6 @@ def test_contruct_release_notes():
479491
+ "* Feature 8 by @new_contributor_1, @new_contributor_coauthor3 and @new_contributor_coauthor4 in https://github.com/ada-url/ada/pull/15\n"
480492
+ "* Feature 9 by @new_contributor_2 and @new_contributor_coauthor1 in https://github.com/ada-url/ada/pull/13\n"
481493
+ "* Feature 7 by @contributor_3 and @new_contributor_coauthor2 in https://github.com/ada-url/ada/pull/14\n"
482-
+ "* Feature 11 by @new_contributor_1 in https://github.com/ada-url/ada/pull/16\n"
483494
+ "\n"
484495
+ "## New Contributors\n"
485496
+ "* @new_contributor_2 and @new_contributor_coauthor1 made their first contribution in https://github.com/ada-url/ada/pull/13\n"

0 commit comments

Comments
 (0)