Skip to content

Commit 4b6a2df

Browse files
More fixes for PR detection among releases
1 parent 8feb5d7 commit 4b6a2df

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

noxfile.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,34 @@ def release(session: nox.Session) -> None:
120120
template_path = DIR / "release_notes" / template_name
121121
template = string.Template(template_path.read_text())
122122

123-
commit_log = subprocess.run(
123+
# Get the date of the previous tag to filter PRs merged after it
124+
prev_date = subprocess.run(
125+
["git", "log", "-1", "--format=%aI", previous_tag],
126+
capture_output=True,
127+
text=True,
128+
check=True,
129+
).stdout.strip()
130+
131+
pr_log = subprocess.run(
124132
[
125-
"git",
126-
"log",
127-
f"{previous_tag}...HEAD",
128-
"--pretty=format:- %s by @%an in %H",
129-
"--no-merges",
133+
"gh",
134+
"pr",
135+
"list",
136+
"--state=merged",
137+
"--search",
138+
f"merged:>{prev_date}",
139+
"--json",
140+
"number,title,author",
141+
"--jq",
142+
'.[] | select(.author.login != "dependabot[bot]" and .author.login != "pre-commit-ci[bot]") | "- \\(.title) by @\\(.author.login) in #\\(.number)"',
130143
],
131144
capture_output=True,
132145
text=True,
133146
check=True,
134147
).stdout.strip()
135148

136-
if commit_log:
137-
changes_section = f"\n## Changes that made it to this release\n\n{commit_log}\n"
149+
if pr_log:
150+
changes_section = f"\n## Changes that made it to this release\n\n{pr_log}\n"
138151
else:
139152
changes_section = ""
140153

0 commit comments

Comments
 (0)