Skip to content

Commit a8cdd72

Browse files
committed
Lookup PRs directly from commit
1 parent 16f977b commit a8cdd72

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

.github/workflows/watch-dependencies.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ jobs:
105105
body: |
106106
Updates mybinder to depend on the `${{ matrix.registry }}/${{ matrix.repository }}` image version `${{ steps.latest.outputs.tag }}` from version `${{ steps.local.outputs.tag }}`.
107107
108-
## Merged PRs:
109108
${{ steps.prsummary.outputs.prs }}
110109
111110
## Related
@@ -239,7 +238,6 @@ jobs:
239238
Chart.yaml's version | `${{ steps.local.outputs.version }}` | `${{ steps.latest.outputs.version }}`
240239
Chart.yaml's appVersion | `${{ steps.local.outputs.appVersion }}` | `${{ steps.latest.outputs.appVersion }}`
241240
242-
## Merged PRs:
243241
${{ steps.prsummary.outputs.prs }}
244242
245243
## Related

scripts/get-prs.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def extract_gitref(s):
3434
action="store_true",
3535
help="Escape output for GitHub Action",
3636
)
37+
parser.add_argument(
38+
"--max-commits",
39+
type=int,
40+
default=100,
41+
help="Maximum number of commits to check",
42+
)
3743

3844
args = parser.parse_args()
3945

@@ -45,16 +51,21 @@ def extract_gitref(s):
4551

4652
prs = set()
4753
git_compare = r.compare(start, end)
48-
for c in git_compare.commits:
49-
s = gh.search_issues("", type="pr", repo=args.repo, sha=c.sha)
50-
prs.update(s)
51-
54+
commits = list(git_compare.commits)
55+
if len(commits) > args.max_commits:
56+
pr_summaries = [
57+
f"{len(commits)} commits between {start} and {end}, not searching for PRs"
58+
]
59+
else:
60+
for c in commits:
61+
prs.update(c.get_pulls())
62+
pr_summaries = [
63+
f"- [#{pr.number}]({pr.html_url}) {pr.title}"
64+
for pr in sorted(prs, key=lambda pr: pr.number)
65+
]
5266

53-
pr_summaries = [
54-
f"- [#{pr.number}]({pr.html_url}) {pr.title}"
55-
for pr in sorted(prs, key=lambda pr: pr.number)
56-
]
67+
md = ["# PRs"] + pr_summaries + ["", f"{r.html_url}/compare/{start}...{end}"]
5768
if args.github_action_escape:
58-
print("%0A".join(pr_summaries))
69+
print("%0A".join(md))
5970
else:
60-
print("\n".join(pr_summaries))
71+
print("\n".join(md))

0 commit comments

Comments
 (0)