@@ -87,7 +87,7 @@ class IssueService extends Base {
8787 * @returns {Promise<object> }
8888 */
8989 async assignIssue ( { issue_number, assignees} ) {
90- if ( ! this . hasWritePermission ( ) ) {
90+ if ( ! await this . hasWritePermission ( ) ) {
9191 const message = [
9292 `Permission denied. Viewer has '${ RepositoryService . viewerPermission } ' permission, ` ,
9393 `but one of [${ this . writePermissions . join ( ', ' ) } ] is required to assign issues.`
@@ -108,12 +108,12 @@ class IssueService extends Base {
108108 if ( assignees ?. length > 0 ) {
109109 logger . info ( `Attempting to assign issue #${ issue_number } to: ${ assignees . join ( ', ' ) } ` ) ;
110110 const assigneeFlags = assignees . map ( a => `--add-assignee "${ a } "` ) . join ( ' ' ) ;
111- command = `gh issue edit ${ issue_number } ${ assigneeFlags } ` ;
111+ command = `gh issue edit ${ issue_number } ${ assigneeFlags } --repo ${ aiConfig . owner } / ${ aiConfig . repo } ` ;
112112 successMessage = `Successfully assigned issue #${ issue_number } to ${ assignees . join ( ', ' ) } ` ;
113113 } else {
114114 logger . info ( `Attempting to unassign all users from issue #${ issue_number } ` ) ;
115115 // Passing an empty string to --remove-assignee has been experimentally verified to clear all assignees.
116- command = `gh issue edit ${ issue_number } --remove-assignee ""` ;
116+ command = `gh issue edit ${ issue_number } --remove-assignee "" --repo ${ aiConfig . owner } / ${ aiConfig . repo } ` ;
117117 successMessage = `Successfully unassigned all users from issue #${ issue_number } ` ;
118118 }
119119
@@ -220,7 +220,7 @@ class IssueService extends Base {
220220
221221 // Permission check is only required if we are trying to assign users.
222222 if ( assignees && assignees . length > 0 ) {
223- if ( ! this . hasWritePermission ( ) ) {
223+ if ( ! await this . hasWritePermission ( ) ) {
224224 const message = [
225225 `Permission denied. Viewer has '${ RepositoryService . viewerPermission } ' permission, ` ,
226226 `but one of [${ this . writePermissions . join ( ', ' ) } ] is required to assign issues.`
@@ -312,10 +312,11 @@ class IssueService extends Base {
312312
313313 /**
314314 * Convenience shortcut
315- * @returns {Boolean }
315+ * @returns {Promise< Boolean> }
316316 */
317- hasWritePermission ( ) {
318- return this . writePermissions . includes ( RepositoryService . viewerPermission ) ;
317+ async hasWritePermission ( ) {
318+ const { permission} = await RepositoryService . getViewerPermission ( ) ;
319+ return this . writePermissions . includes ( permission ) ;
319320 }
320321
321322 /**
@@ -417,7 +418,7 @@ class IssueService extends Base {
417418 * @returns {Promise<object> }
418419 */
419420 async unassignIssue ( { issue_number, assignees} ) {
420- if ( ! this . hasWritePermission ( ) ) {
421+ if ( ! await this . hasWritePermission ( ) ) {
421422 const message = [
422423 `Permission denied. Viewer has '${ RepositoryService . viewerPermission } ' permission, ` ,
423424 `but one of [${ this . writePermissions . join ( ', ' ) } ] is required to unassign issues.`
@@ -443,7 +444,7 @@ class IssueService extends Base {
443444
444445 try {
445446 const assigneeFlags = assignees . map ( a => `--remove-assignee "${ a } "` ) . join ( ' ' ) ;
446- const command = `gh issue edit ${ issue_number } ${ assigneeFlags } ` ;
447+ const command = `gh issue edit ${ issue_number } ${ assigneeFlags } --repo ${ aiConfig . owner } / ${ aiConfig . repo } ` ;
447448
448449 await execAsync ( command ) ;
449450
0 commit comments