Apply early exit strategy for better readability

This commit is contained in:
Sergey Dolin 2023-01-26 21:19:56 +01:00
parent c4a13d8dca
commit 65920a0bde

View File

@ -923,10 +923,19 @@ export class IssuesProcessor {
const branch = pullRequest.head.ref; const branch = pullRequest.head.ref;
if ( if (
pullRequest.head.repo === null || pullRequest.head.repo?.full_name !==
pullRequest.head.repo.full_name ===
`${context.repo.owner}/${context.repo.repo}` `${context.repo.owner}/${context.repo.repo}`
) { ) {
issueLogger.warning(
`Deleting the branch "${LoggerService.cyan(
branch
)}" has skipped because it belongs to other repo ${
pullRequest.head.repo!.full_name
}`
);
return;
}
issueLogger.info( issueLogger.info(
`Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type` `Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type`
); );
@ -949,15 +958,6 @@ export class IssuesProcessor {
)}" from $$type: ${error.message}` )}" 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
}`
);
}
} }
// Remove a label from an issue or a pull request // Remove a label from an issue or a pull request