Skip to content

Commit 5f07402

Browse files
committed
chore: loads of logs
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent a4f47bb commit 5f07402

1 file changed

Lines changed: 63 additions & 23 deletions

File tree

.github/scripts/bots/assign-01-gfi-auto.js

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@
77
* - This file only orchestrates
88
*/
99

10-
const { isTeam } =
11-
require('../lib/team/has-team');
12-
13-
const { hasGfiEligibility } =
14-
require('../lib/eligibility/has-eligibility-01-gfi');
15-
16-
const { rejectionRouter } =
17-
require('../lib/comments/rejection-router');
18-
19-
const { assignReminder } =
20-
require('../lib/comments/reminder-to-request-assign');
21-
22-
const { alreadyAssigned } =
23-
require('../lib/comments/issue-already-assigned');
10+
const { isTeam } = require('../lib/team/has-team');
11+
const { hasGfiEligibility } = require('../lib/eligibility/has-eligibility-01-gfi');
12+
const { rejectionRouter } = require('../lib/comments/rejection-router');
13+
const { assignReminder } = require('../lib/comments/reminder-to-request-assign');
14+
const { alreadyAssigned } = require('../lib/comments/issue-already-assigned');
2415

2516
const GOOD_FIRST_ISSUE_LABEL = 'Good First Issue';
2617
const ASSIGN_REMINDER_MARKER = '<!-- GFI assign reminder -->';
@@ -41,26 +32,48 @@ module.exports = async ({ github, context }) => {
4132
const { issue, comment } = context.payload;
4233
const { owner, repo } = context.repo;
4334

44-
if (!issue || !comment) return;
45-
if (comment.user?.type === 'Bot') return;
46-
if (!isGfiIssue(issue)) return;
35+
// ─────────────────────────────────────────────
36+
// Guard rails & early exits
37+
// ─────────────────────────────────────────────
38+
if (!issue || !comment) {
39+
console.log('[gfi-assign] Exit: missing issue or comment');
40+
return;
41+
}
42+
43+
if (comment.user?.type === 'Bot') {
44+
console.log('[gfi-assign] Exit: comment authored by bot');
45+
return;
46+
}
47+
48+
if (!isGfiIssue(issue)) {
49+
console.log('[gfi-assign] Exit: issue is not Good First Issue', {
50+
labels: issue.labels?.map(l => l.name),
51+
});
52+
return;
53+
}
4754

4855
const username = comment.user.login;
4956

5057
console.log('[gfi-assign] Start', {
5158
issue: issue.number,
5259
username,
60+
commentBody: comment.body,
5361
});
5462

5563
// ─────────────────────────────────────────────
56-
// Gentle reminder if user comments but not /assign
57-
// (exclude team members)
64+
// Reminder flow (no /assign)
5865
// ─────────────────────────────────────────────
5966
if (!requestsAssignment(comment.body)) {
60-
if (
61-
!issue.assignees?.length &&
62-
!(await isTeam({ github, owner, repo, username }))
63-
) {
67+
console.log('[gfi-assign] No /assign detected, evaluating reminder');
68+
69+
const isTeamMember = await isTeam({ github, owner, repo, username });
70+
71+
console.log('[gfi-assign] Reminder eligibility', {
72+
isTeamMember,
73+
hasAssignee: !!issue.assignees?.length,
74+
});
75+
76+
if (!issue.assignees?.length && !isTeamMember) {
6477
const comments = await github.paginate(
6578
github.rest.issues.listComments,
6679
{
@@ -75,6 +88,10 @@ module.exports = async ({ github, context }) => {
7588
c.body?.includes(ASSIGN_REMINDER_MARKER)
7689
);
7790

91+
console.log('[gfi-assign] Reminder presence', {
92+
alreadyReminded,
93+
});
94+
7895
if (!alreadyReminded) {
7996
await github.rest.issues.createComment({
8097
owner,
@@ -89,13 +106,20 @@ module.exports = async ({ github, context }) => {
89106
}
90107
}
91108

109+
console.log('[gfi-assign] Exit: reminder path complete');
92110
return;
93111
}
94112

113+
console.log('[gfi-assign] /assign command detected');
114+
95115
// ─────────────────────────────────────────────
96116
// Already assigned
97117
// ─────────────────────────────────────────────
98118
if (issue.assignees?.length) {
119+
console.log('[gfi-assign] Exit: issue already assigned', {
120+
assignee: issue.assignees[0]?.login,
121+
});
122+
99123
await github.rest.issues.createComment({
100124
owner,
101125
repo,
@@ -107,6 +131,7 @@ module.exports = async ({ github, context }) => {
107131
tierLabel: 'Good First',
108132
}),
109133
});
134+
110135
return;
111136
}
112137

@@ -120,6 +145,11 @@ module.exports = async ({ github, context }) => {
120145
username,
121146
});
122147

148+
console.log('[gfi-assign] Eligibility result', {
149+
username,
150+
result,
151+
});
152+
123153
if (!result.eligible) {
124154
const body = rejectionRouter({
125155
reason: result.reason,
@@ -128,6 +158,11 @@ module.exports = async ({ github, context }) => {
128158
urls: BROWSE_URLS,
129159
});
130160

161+
console.log('[gfi-assign] Rejection routed', {
162+
reason: result.reason,
163+
hasBody: !!body,
164+
});
165+
131166
if (body) {
132167
await github.rest.issues.createComment({
133168
owner,
@@ -143,6 +178,11 @@ module.exports = async ({ github, context }) => {
143178
// ─────────────────────────────────────────────
144179
// Assign issue
145180
// ─────────────────────────────────────────────
181+
console.log('[gfi-assign] Assigning issue', {
182+
issue: issue.number,
183+
assignee: username,
184+
});
185+
146186
await github.rest.issues.addAssignees({
147187
owner,
148188
repo,

0 commit comments

Comments
 (0)