diff --git a/dist/index.js b/dist/index.js index c06b77275..86cccf8b6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -517,8 +517,7 @@ class IssuesProcessor { return __awaiter(this, void 0, void 0, function* () { const issueLogger = new issue_logger_1.IssueLogger(issue); issueLogger.info(`Checking for label on $$type`); - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsEventsCount(); const options = this.client.issues.listEvents.endpoint.merge({ owner: github_1.context.repo.owner, @@ -606,8 +605,7 @@ class IssuesProcessor { } if (!skipMessage) { try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue); yield this.client.issues.createComment({ owner: github_1.context.repo.owner, @@ -621,8 +619,7 @@ class IssuesProcessor { } } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue); (_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementStaleItemsCount(issue); yield this.client.issues.addLabels({ @@ -649,8 +646,7 @@ class IssuesProcessor { } if (closeMessage) { try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue); yield this.client.issues.createComment({ owner: github_1.context.repo.owner, @@ -665,8 +661,7 @@ class IssuesProcessor { } if (closeLabel) { try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue); yield this.client.issues.addLabels({ owner: github_1.context.repo.owner, @@ -680,8 +675,7 @@ class IssuesProcessor { } } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue); yield this.client.issues.update({ owner: github_1.context.repo.owner, @@ -703,8 +697,7 @@ class IssuesProcessor { return; } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount(); const pullRequest = yield this.client.pulls.get({ owner: github_1.context.repo.owner, @@ -735,8 +728,7 @@ class IssuesProcessor { const branch = pullRequest.head.ref; issueLogger.info(`Deleting the branch "${chalk_1.default.cyan(branch)}" from closed $$type`); try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedBranchesCount(); yield this.client.git.deleteRef({ owner: github_1.context.repo.owner, @@ -760,8 +752,7 @@ class IssuesProcessor { return; } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedItemsLabelsCount(issue); yield this.client.issues.removeLabel({ owner: github_1.context.repo.owner, @@ -859,6 +850,10 @@ class IssuesProcessor { } }); } + _consumeIssueOperation(issue) { + this._operations.consumeOperation(); + issue.operations.consumeOperation(); + } } exports.IssuesProcessor = IssuesProcessor; diff --git a/src/classes/issues-processor.ts b/src/classes/issues-processor.ts index 3c2bf3b8f..108034248 100644 --- a/src/classes/issues-processor.ts +++ b/src/classes/issues-processor.ts @@ -374,8 +374,8 @@ export class IssuesProcessor { // Grab comments for an issue since a given date async listIssueComments( - issueNumber: number, - sinceDate: string + issueNumber: Readonly, + sinceDate: Readonly ): Promise { // Find any comments since date on the given issue try { @@ -447,8 +447,7 @@ export class IssuesProcessor { issueLogger.info(`Checking for label on $$type`); - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementFetchedItemsEventsCount(); const options = this.client.issues.listEvents.endpoint.merge({ owner: context.repo.owner, @@ -592,8 +591,7 @@ export class IssuesProcessor { if (!skipMessage) { try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementAddedItemsComment(issue); await this.client.issues.createComment({ owner: context.repo.owner, @@ -607,8 +605,7 @@ export class IssuesProcessor { } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementAddedItemsLabel(issue); this._statistics?.incrementStaleItemsCount(issue); await this.client.issues.addLabels({ @@ -639,8 +636,7 @@ export class IssuesProcessor { if (closeMessage) { try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementAddedItemsComment(issue); await this.client.issues.createComment({ owner: context.repo.owner, @@ -655,8 +651,7 @@ export class IssuesProcessor { if (closeLabel) { try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementAddedItemsLabel(issue); await this.client.issues.addLabels({ owner: context.repo.owner, @@ -670,8 +665,7 @@ export class IssuesProcessor { } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementClosedItemsCount(issue); await this.client.issues.update({ owner: context.repo.owner, @@ -694,8 +688,7 @@ export class IssuesProcessor { } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementFetchedPullRequestsCount(); const pullRequest = await this.client.pulls.get({ owner: context.repo.owner, @@ -734,8 +727,7 @@ export class IssuesProcessor { ); try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementDeletedBranchesCount(); await this.client.git.deleteRef({ owner: context.repo.owner, @@ -765,8 +757,7 @@ export class IssuesProcessor { } try { - this._operations.consumeOperation(); - issue.operations.consumeOperation(); + this._consumeIssueOperation(issue); this._statistics?.incrementDeletedItemsLabelsCount(issue); await this.client.issues.removeLabel({ owner: context.repo.owner, @@ -891,4 +882,9 @@ export class IssuesProcessor { this._statistics?.incrementDeletedCloseItemsLabelsCount(issue); } } + + private _consumeIssueOperation(issue: Readonly): void { + this._operations.consumeOperation(); + issue.operations.consumeOperation(); + } }