1- import type { Octokit } from ' @octokit/core' ;
2- import { Issue } from ' ./Issue.js' ;
1+ import type { Octokit } from " @octokit/core" ;
2+ import { Issue } from " ./Issue.js" ;
33
44// https://docs.github.com/en/enterprise-cloud@latest/copilot/how-tos/use-copilot-agents/coding-agent/assign-copilot-to-an-issue#assigning-an-existing-issue
5- export async function assignIssue ( octokit : Octokit , { owner, repository, issueNumber, nodeId } : Issue ) {
5+ export async function assignIssue (
6+ octokit : Octokit ,
7+ { owner, repository, issueNumber, nodeId } : Issue
8+ ) {
69 // Check whether issues can be assigned to Copilot
710 const suggestedActorsResponse = await octokit . graphql < {
811 repository : {
912 suggestedActors : {
10- nodes : { login : string , id : string } [ ]
11- }
12- }
13+ nodes : { login : string ; id : string } [ ] ;
14+ } ;
15+ } ;
1316 } > (
1417 `query ($owner: String!, $repository: String!) {
1518 repository(owner: $owner, name: $repository) {
@@ -23,19 +26,24 @@ export async function assignIssue(octokit: Octokit, { owner, repository, issueNu
2326 }
2427 }
2528 }` ,
26- { owner, repository } ,
29+ { owner, repository }
2730 ) ;
28- if ( suggestedActorsResponse ?. repository ?. suggestedActors ?. nodes [ 0 ] ?. login !== "copilot-swe-agent" ) {
31+ if (
32+ suggestedActorsResponse ?. repository ?. suggestedActors ?. nodes [ 0 ] ?. login !==
33+ "copilot-swe-agent"
34+ ) {
2935 return ;
3036 }
3137 // Get GraphQL identifier for issue (unless already provided)
3238 let issueId = nodeId ;
3339 if ( ! issueId ) {
34- console . debug ( `Fetching identifier for issue ${ owner } /${ repository } #${ issueNumber } ` ) ;
40+ console . debug (
41+ `Fetching identifier for issue ${ owner } /${ repository } #${ issueNumber } `
42+ ) ;
3543 const issueResponse = await octokit . graphql < {
3644 repository : {
37- issue : { id : string }
38- }
45+ issue : { id : string } ;
46+ } ;
3947 } > (
4048 `query($owner: String!, $repository: String!, $issueNumber: Int!) {
4149 repository(owner: $owner, name: $repository) {
@@ -45,33 +53,37 @@ export async function assignIssue(octokit: Octokit, { owner, repository, issueNu
4553 { owner, repository, issueNumber }
4654 ) ;
4755 issueId = issueResponse ?. repository ?. issue ?. id ;
48- console . debug ( `Fetched identifier for issue ${ owner } /${ repository } #${ issueNumber } : ${ issueId } ` ) ;
56+ console . debug (
57+ `Fetched identifier for issue ${ owner } /${ repository } #${ issueNumber } : ${ issueId } `
58+ ) ;
4959 } else {
50- console . debug ( `Using provided identifier for issue ${ owner } /${ repository } #${ issueNumber } : ${ issueId } ` ) ;
60+ console . debug (
61+ `Using provided identifier for issue ${ owner } /${ repository } #${ issueNumber } : ${ issueId } `
62+ ) ;
5163 }
5264 if ( ! issueId ) {
53- console . warn ( `Couldn’t get identifier for issue ${ owner } /${ repository } #${ issueNumber } . Skipping assignment to Copilot.` ) ;
65+ console . warn (
66+ `Couldn’t get identifier for issue ${ owner } /${ repository } #${ issueNumber } . Skipping assignment to Copilot.`
67+ ) ;
5468 return ;
5569 }
5670 // Assign issue to Copilot
5771 await octokit . graphql < {
5872 replaceActorsForAssignable : {
5973 assignable : {
6074 id : string ;
61- url : string ;
6275 title : string ;
6376 assignees : {
64- nodes : { login : string } [ ]
65- }
66- }
67- }
77+ nodes : { login : string } [ ] ;
78+ } ;
79+ } ;
80+ } ;
6881 } > (
6982 `mutation($issueId: ID!, $assigneeId: ID!) {
7083 replaceActorsForAssignable(input: {assignableId: $issueId, actorIds: [$assigneeId]}) {
7184 assignable {
7285 ... on Issue {
7386 id
74- url
7587 title
7688 assignees(first: 10) {
7789 nodes {
@@ -82,6 +94,10 @@ export async function assignIssue(octokit: Octokit, { owner, repository, issueNu
8294 }
8395 }
8496 }` ,
85- { issueId, assigneeId : suggestedActorsResponse ?. repository ?. suggestedActors ?. nodes [ 0 ] ?. id }
97+ {
98+ issueId,
99+ assigneeId :
100+ suggestedActorsResponse ?. repository ?. suggestedActors ?. nodes [ 0 ] ?. id ,
101+ }
86102 ) ;
87- }
103+ }
0 commit comments