Merged PR role count can double-count when the current PR is outside the first search page

未关闭 适合新手
#108 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
github, typescript
领域
api, backend

调研方向

找到 countMergedPrs 和 onPullRequest,然后阅读有关搜索结果和 exceptUrl 情况的现有测试。使用 total_count: 101 和不包含当前 PR 的 100 个项目重现问题;确保即使当前 PR 不在第一页中,之前的计数也会将其排除。webhook 使用正确的计数评估角色阈值时即为完成。

由索引模型根据 Issue 内容生成。

描述

Bug

countMergedPrs requests only the first 100 GitHub search results, then uses total_count for the full result set. When called from the merged-PR webhook with exceptUrl, it subtracts one only if the current PR is present in those first 100 items.

For a linked contributor with more than 100 merged PRs, GitHub can include the just-merged PR in total_count but omit it from the first page. In that case countMergedPrs(..., pr.html_url) returns a count that already includes the current PR. onPullRequest then adds one again (earlier + 1), which can grant a contributor role one merge earlier than its configured threshold.

Reproduction

  1. Mock a GitHub search response with total_count: 101 and 100 items that do not include the current PR URL.
  2. Call countMergedPrs with exceptUrl set to that current PR URL.
  3. The function returns 101 instead of 100 because it cannot tell whether the omitted 101st result is the current PR.
  4. The webhook adds one and evaluates role tiers using 102.

Expected behavior

The webhook's earlier-PR count should exclude the current PR even when it is not on the first search page, so role thresholds are evaluated against an accurate count.

主要语言
TypeScript
星标
0
派生
1
平均合并
2 小时 38 分钟
30 天内合并 PR
73

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codercops/discord-bot 的其他 Issue

查看 codercops/discord-bot 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。