Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
benvillalobos committed Jun 7, 2021
1 parent 7596639 commit 87fbc5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
1 change: 1 addition & 0 deletions __tests__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ test('stale label should be removed if a comment was added to a stale issue', as
});

test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
expect.assertions(4);
const opts = {
...DefaultProcessorOptions,
removeStaleWhenUpdated: true,
Expand Down
19 changes: 9 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -865,20 +865,19 @@ class IssuesProcessor {
return;
}
const issueLogger = new issue_logger_1.IssueLogger(issue);
issueLogger.info(`Removing all the labels specified via the ${this._logger.createOptionLink(option_1.Option.LabelsToAddWhenUnstale)} option.`);
issueLogger.info(`Adding all the labels specified via the ${this._logger.createOptionLink(option_1.Option.LabelsToAddWhenUnstale)} option.`);
this.addedLabelIssues.push(issue);
if (this.options.debugOnly) {
return;
}
try {
this._operations.consumeOperation();
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsLabel(issue);
yield this.client.issues.addLabels({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
issue_number: issue.number,
labels: addLabels
});
if (!this.options.debugOnly) {
yield this.client.issues.addLabels({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
issue_number: issue.number,
labels: addLabels
});
}
}
catch (error) {
this._logger.error(`Error when adding labels after updated from stale: ${error.message}`);
Expand Down
18 changes: 8 additions & 10 deletions src/classes/issues-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -998,19 +998,17 @@ export class IssuesProcessor {

this.addedLabelIssues.push(issue);

if (this.options.debugOnly) {
return;
}

try {
this._operations.consumeOperation();
this._statistics?.incrementAddedItemsLabel(issue);
await this.client.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: addLabels
});
if (!this.options.debugOnly) {
await this.client.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: addLabels
});
}
} catch (error) {
this._logger.error(
`Error when adding labels after updated from stale: ${error.message}`
Expand Down

0 comments on commit 87fbc5e

Please sign in to comment.