diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 75024b9c..c752d320 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -923,40 +923,40 @@ export class IssuesProcessor { const branch = pullRequest.head.ref; if ( - pullRequest.head.repo === null || - pullRequest.head.repo.full_name === - `${context.repo.owner}/${context.repo.repo}` + pullRequest.head.repo?.full_name !== + `${context.repo.owner}/${context.repo.repo}` ) { - issueLogger.info( - `Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type` - ); - - try { - this._consumeIssueOperation(issue); - this.statistics?.incrementDeletedBranchesCount(); - - if (!this.options.debugOnly) { - await this.client.rest.git.deleteRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `heads/${branch}` - }); - } - } catch (error) { - issueLogger.error( - `Error when deleting the branch "${LoggerService.cyan( - branch - )}" from $$type: ${error.message}` - ); - } - } else { issueLogger.warning( `Deleting the branch "${LoggerService.cyan( branch )}" has skipped because it belongs to other repo ${ - pullRequest.head.repo.full_name + pullRequest.head.repo!.full_name }` ); + return; + } + + issueLogger.info( + `Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type` + ); + + try { + this._consumeIssueOperation(issue); + this.statistics?.incrementDeletedBranchesCount(); + + if (!this.options.debugOnly) { + await this.client.rest.git.deleteRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: `heads/${branch}` + }); + } + } catch (error) { + issueLogger.error( + `Error when deleting the branch "${LoggerService.cyan( + branch + )}" from $$type: ${error.message}` + ); } }