diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 07aff68f..75024b9c 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -921,26 +921,41 @@ export class IssuesProcessor { } const branch = pullRequest.head.ref; - issueLogger.info( - `Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type` - ); - try { - this._consumeIssueOperation(issue); - this.statistics?.incrementDeletedBranchesCount(); + if ( + pullRequest.head.repo === null || + pullRequest.head.repo.full_name === + `${context.repo.owner}/${context.repo.repo}` + ) { + issueLogger.info( + `Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type` + ); - if (!this.options.debugOnly) { - await this.client.rest.git.deleteRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: `heads/${branch}` - }); + 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}` + ); } - } catch (error) { - issueLogger.error( - `Error when deleting the branch "${LoggerService.cyan( + } else { + issueLogger.warning( + `Deleting the branch "${LoggerService.cyan( branch - )}" from $$type: ${error.message}` + )}" has skipped because it belongs to other repo ${ + pullRequest.head.repo.full_name + }` ); } } diff --git a/src/interfaces/pull-request.ts b/src/interfaces/pull-request.ts index bea212b6..9b8e0329 100644 --- a/src/interfaces/pull-request.ts +++ b/src/interfaces/pull-request.ts @@ -2,6 +2,9 @@ export interface IPullRequest { number: number; head: { ref: string; + repo: { + full_name: string; + } | null; }; draft?: boolean; }