Skip to content

Commit c5e34a2

Browse files
authored
ci: Fix 2nd instance of PR Quota message formatting (#8131)
Signed-off-by: Yuri Shkuro <github@ysh.us>
1 parent f23ef6f commit c5e34a2

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/scripts/pr-quota-manager.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
const LABEL_NAME = 'pr-quota-reached';
1616
const LABEL_COLOR = 'CFD3D7';
1717

18+
/**
19+
* Format open/limit counts as a bullet-point status block
20+
* @param {number} openCount - Number of currently open PRs
21+
* @param {number} quota - Allowed quota
22+
* @returns {string} Formatted status string
23+
*/
24+
function formatStatus(openCount, quota) {
25+
return ` * Open: ${openCount}\n * Limit: ${quota}`;
26+
}
27+
1828
/**
1929
* Calculate the quota for a user based on their merged PR count
2030
* @param {number} mergedCount - Number of merged PRs
@@ -279,8 +289,7 @@ async function postBlockingComment(octokit, owner, repo, issueNumber, author, op
279289
}
280290

281291
const message = `Hi @${author}, thanks for your contribution! To ensure quality reviews, we limit how many concurrent PRs new contributors can open:
282-
* Open: ${openCount}
283-
* Limit: ${quota}
292+
${formatStatus(openCount, quota)}
284293
285294
This PR is currently **on hold**. We will automatically move this into the review queue once your existing PRs are merged or closed.
286295
@@ -303,9 +312,12 @@ Please see our [Contributing Guidelines](https://github.com/jaegertracing/jaeger
303312
* Always posts when called - if PR was blocked again after being unblocked, user should be notified again
304313
*/
305314
async function postUnblockingComment(octokit, owner, repo, issueNumber, author, openCount, quota, logger) {
306-
const message = `PR quota unlocked! @${author}, this PR has been moved out of the waiting room and into the active review queue. Thank you for your patience.
315+
const message = `PR quota unlocked!
316+
317+
@${author}, this PR has been moved out of the waiting room and into the active review queue:
318+
${formatStatus(openCount, quota)}
307319
308-
**Current Status:** ${openCount}/${quota} open.`;
320+
Thank you for your patience.`;
309321

310322
try {
311323
await octokit.rest.issues.createComment({
@@ -399,6 +411,7 @@ if (typeof module !== 'undefined' && module.exports) {
399411
module.exports = githubActionHandler;
400412

401413
// Named exports for testing and direct usage
414+
module.exports.formatStatus = formatStatus;
402415
module.exports.calculateQuota = calculateQuota;
403416
module.exports.fetchAuthorPRs = fetchAuthorPRs;
404417
module.exports.processQuotaForAuthor = processQuotaForAuthor;

.github/scripts/pr-quota-manager.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
const prQuotaManager = require('./pr-quota-manager');
66
const {
7+
formatStatus,
78
calculateQuota,
89
fetchAuthorPRs,
910
processQuotaForAuthor,
@@ -23,6 +24,12 @@ const mockLogger = {
2324
error: jest.fn()
2425
};
2526

27+
describe('formatStatus', () => {
28+
test('formats open count and quota as bullet points', () => {
29+
expect(formatStatus(3, 5)).toBe(' * Open: 3\n * Limit: 5');
30+
});
31+
});
32+
2633
describe('calculateQuota', () => {
2734
test('returns 1 for 0 merged PRs', () => {
2835
expect(calculateQuota(0)).toBe(1);

0 commit comments

Comments
 (0)