Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit da4343d

Browse files
authored
Add support for assigning cc'ed users to issues based on available triagers (#338)
1 parent d081955 commit da4343d

File tree

2 files changed

+35
-39
lines changed

2 files changed

+35
-39
lines changed

classifier-deep/apply/apply-labels/index.js

Lines changed: 16 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classifier-deep/apply/apply-labels/index.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class ApplyLabels extends Action {
4747
readFileSync(join(__dirname, '../issue_labels.json'), { encoding: 'utf8' }),
4848
);
4949

50+
const vscodeToolsAPI = new VSCodeToolsAPIManager();
51+
const triagers = await vscodeToolsAPI.getTriagerGitHubIds();
52+
5053
for (const labeling of labelings) {
5154
const issue = new OctoKitIssue(token, { owner, repo }, { number: labeling.number });
5255

@@ -81,6 +84,22 @@ class ApplyLabels extends Action {
8184
continue;
8285
}
8386

87+
// Check if the issue has any cc'ed users and assign them if they are available
88+
const issueBody = issueData.body;
89+
const ccMatches = (issueBody.match(/@(\w+)/g) || []).map((match) => match.replace('@', ''));
90+
let performedAssignment = false;
91+
for (const ccMatch of ccMatches) {
92+
if (triagers.includes(ccMatch)) {
93+
safeLog("assigning cc'ed user", ccMatch);
94+
performedAssignment = true;
95+
await issue.addAssignee(ccMatch);
96+
}
97+
}
98+
99+
if (performedAssignment) {
100+
continue;
101+
}
102+
84103
safeLog(
85104
'not skipping',
86105
JSON.stringify({
@@ -144,7 +163,6 @@ class ApplyLabels extends Action {
144163
}
145164
}
146165

147-
let performedAssignment = false;
148166
if (potentialAssignees.length && !debug) {
149167
for (const assignee of potentialAssignees) {
150168
const hasBeenAssigned = await issue.getAssigner(assignee).catch(() => undefined);
@@ -159,29 +177,8 @@ class ApplyLabels extends Action {
159177
if (!performedAssignment) {
160178
safeLog('could not find assignee, picking a random one...');
161179
try {
162-
const vscodeToolsAPI = new VSCodeToolsAPIManager();
163-
const triagers = await vscodeToolsAPI.getTriagerGitHubIds();
164-
safeLog('Acquired list of available triagers');
165180
const available = triagers;
166181
if (available) {
167-
// Check if the issue has any cc'ed users and assign them if they are available
168-
const issueBody = issueData.body;
169-
const ccMatches = (issueBody.match(/@(\w+)/g) || []).map((match) =>
170-
match.replace('@', ''),
171-
);
172-
173-
for (const ccMatch of ccMatches) {
174-
if (available.includes(ccMatch)) {
175-
safeLog("assigning cc'ed user", ccMatch);
176-
await issue.addAssignee(ccMatch);
177-
performedAssignment = true;
178-
}
179-
}
180-
181-
if (performedAssignment) {
182-
continue;
183-
}
184-
185182
// Shuffle the array
186183
for (let i = available.length - 1; i > 0; i--) {
187184
const j = Math.floor(Math.random() * (i + 1));

0 commit comments

Comments
 (0)