@@ -12,6 +12,58 @@ import {
12
12
getSize ,
13
13
} from './projects.js'
14
14
15
+ /**
16
+ * Determines if a PR is authored by Copilot and extracts the human assignee
17
+ * @param data GraphQL response data containing PR information
18
+ * @returns Object with isCopilotAuthor boolean and copilotAssignee string
19
+ */
20
+ function getCopilotAuthorInfo ( data : Record < string , any > ) : {
21
+ isCopilotAuthor : boolean
22
+ copilotAssignee : string
23
+ } {
24
+ // Check if this is a Copilot-authored PR
25
+ const isCopilotAuthor =
26
+ data . item . __typename === 'PullRequest' &&
27
+ data . item . author &&
28
+ data . item . author . login === 'copilot-swe-agent'
29
+
30
+ // For Copilot PRs, find the appropriate assignee (excluding Copilot itself)
31
+ let copilotAssignee = ''
32
+ if ( isCopilotAuthor && data . item . assignees && data . item . assignees . nodes ) {
33
+ const assignees = data . item . assignees . nodes
34
+ . map ( ( assignee : Record < string , any > ) => assignee . login )
35
+ . filter ( ( login : string ) => login !== 'copilot-swe-agent' )
36
+
37
+ // Use the first non-Copilot assignee
38
+ copilotAssignee = assignees . length > 0 ? assignees [ 0 ] : ''
39
+ }
40
+
41
+ return { isCopilotAuthor, copilotAssignee }
42
+ }
43
+
44
+ /**
45
+ * Determines the appropriate author field value based on contributor type
46
+ * @param isCopilotAuthor Whether the PR is authored by Copilot
47
+ * @param copilotAssignee The human assignee for Copilot PRs (empty string if none)
48
+ * @param firstTimeContributor Whether this is a first-time contributor
49
+ * @returns The formatted author field value
50
+ */
51
+ function getAuthorFieldValue (
52
+ isCopilotAuthor : boolean ,
53
+ copilotAssignee : string ,
54
+ firstTimeContributor : boolean | undefined ,
55
+ ) : string {
56
+ if ( isCopilotAuthor ) {
57
+ return copilotAssignee ? `Copilot + ${ copilotAssignee } ` : 'Copilot'
58
+ }
59
+
60
+ if ( firstTimeContributor ) {
61
+ return ':star: first time contributor'
62
+ }
63
+
64
+ return process . env . AUTHOR_LOGIN || ''
65
+ }
66
+
15
67
async function run ( ) {
16
68
// Get info about the docs-content review board project
17
69
const data : Record < string , any > = await graphql (
@@ -48,6 +100,14 @@ async function run() {
48
100
path
49
101
}
50
102
}
103
+ author {
104
+ login
105
+ }
106
+ assignees(first: 10) {
107
+ nodes {
108
+ login
109
+ }
110
+ }
51
111
}
52
112
}
53
113
}
@@ -141,17 +201,31 @@ async function run() {
141
201
}
142
202
}
143
203
const turnaround = process . env . REPO === 'github/docs' ? 3 : 2
204
+
205
+ // Check if this is a Copilot-authored PR and get the human assignee
206
+ const { isCopilotAuthor, copilotAssignee } = getCopilotAuthorInfo ( data )
207
+
208
+ // Determine the author field value
209
+ const authorFieldValue = getAuthorFieldValue (
210
+ isCopilotAuthor ,
211
+ copilotAssignee ,
212
+ firstTimeContributor ,
213
+ )
214
+
144
215
// Generate a mutation to populate fields for the new project item
145
216
const updateProjectV2ItemMutation = generateUpdateProjectV2ItemFieldMutation ( {
146
217
item : newItemID ,
147
- author : firstTimeContributor ? ':star: first time contributor' : process . env . AUTHOR_LOGIN || '' ,
218
+ author : authorFieldValue ,
148
219
turnaround,
149
220
feature,
150
221
} )
151
222
152
223
// Determine which variable to use for the contributor type
153
224
let contributorType
154
- if ( await isDocsTeamMember ( process . env . AUTHOR_LOGIN || '' ) ) {
225
+ if ( isCopilotAuthor ) {
226
+ // Treat Copilot PRs as Docs team
227
+ contributorType = docsMemberTypeID
228
+ } else if ( await isDocsTeamMember ( process . env . AUTHOR_LOGIN || '' ) ) {
155
229
contributorType = docsMemberTypeID
156
230
} else if ( await isGitHubOrgMember ( process . env . AUTHOR_LOGIN || '' ) ) {
157
231
contributorType = hubberTypeID
@@ -185,6 +259,8 @@ async function run() {
185
259
return newItemID
186
260
}
187
261
262
+ export { run }
263
+
188
264
run ( ) . catch ( ( error ) => {
189
265
console . log ( `#ERROR# ${ error } ` )
190
266
process . exit ( 1 )
0 commit comments