fix(dry-run): forbid mutations in dry-run (#500)

Bring back the dry-run by default for the tests - bad idea to disable it sorry
Fix bad documentation array format
Fixes #499
This commit is contained in:
Geoffrey Testelin
2021-06-10 16:14:45 +02:00
committed by GitHub
parent b1da9e1fb1
commit f1017f33dd
4 changed files with 66 additions and 55 deletions

View File

@@ -25,7 +25,7 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
anyOfIssueLabels: '', anyOfIssueLabels: '',
anyOfPrLabels: '', anyOfPrLabels: '',
operationsPerRun: 100, operationsPerRun: 100,
debugOnly: false, debugOnly: true,
removeStaleWhenUpdated: false, removeStaleWhenUpdated: false,
removeIssueStaleWhenUpdated: undefined, removeIssueStaleWhenUpdated: undefined,
removePrStaleWhenUpdated: undefined, removePrStaleWhenUpdated: undefined,

8
dist/index.js vendored
View File

@@ -661,6 +661,7 @@ class IssuesProcessor {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(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); (_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementStaleItemsCount(issue);
if (!this.options.debugOnly) {
yield this.client.issues.addLabels({ yield this.client.issues.addLabels({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@@ -668,6 +669,7 @@ class IssuesProcessor {
labels: [staleLabel] labels: [staleLabel]
}); });
} }
}
catch (error) { catch (error) {
issueLogger.error(`Error when adding a label: ${error.message}`); issueLogger.error(`Error when adding a label: ${error.message}`);
} }
@@ -701,6 +703,7 @@ class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue); (_b = this._statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) {
yield this.client.issues.addLabels({ yield this.client.issues.addLabels({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@@ -708,6 +711,7 @@ class IssuesProcessor {
labels: [closeLabel] labels: [closeLabel]
}); });
} }
}
catch (error) { catch (error) {
issueLogger.error(`Error when adding a label: ${error.message}`); issueLogger.error(`Error when adding a label: ${error.message}`);
} }
@@ -715,6 +719,7 @@ class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue); (_c = this._statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue);
if (!this.options.debugOnly) {
yield this.client.issues.update({ yield this.client.issues.update({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@@ -722,6 +727,7 @@ class IssuesProcessor {
state: 'closed' state: 'closed'
}); });
} }
}
catch (error) { catch (error) {
issueLogger.error(`Error when updating this $$type: ${error.message}`); issueLogger.error(`Error when updating this $$type: ${error.message}`);
} }
@@ -734,7 +740,6 @@ class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
(_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount(); (_a = this._statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount();
if (!this.options.debugOnly) {
const pullRequest = yield this.client.pulls.get({ const pullRequest = yield this.client.pulls.get({
owner: github_1.context.repo.owner, owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo, repo: github_1.context.repo.repo,
@@ -742,7 +747,6 @@ class IssuesProcessor {
}); });
return pullRequest.data; return pullRequest.data;
} }
}
catch (error) { catch (error) {
issueLogger.error(`Error when getting this $$type: ${error.message}`); issueLogger.error(`Error when getting this $$type: ${error.message}`);
} }

View File

@@ -740,12 +740,15 @@ export class IssuesProcessor {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementAddedItemsLabel(issue); this._statistics?.incrementAddedItemsLabel(issue);
this._statistics?.incrementStaleItemsCount(issue); this._statistics?.incrementStaleItemsCount(issue);
if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
labels: [staleLabel] labels: [staleLabel]
}); });
}
} catch (error) { } catch (error) {
issueLogger.error(`Error when adding a label: ${error.message}`); issueLogger.error(`Error when adding a label: ${error.message}`);
} }
@@ -784,12 +787,15 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementAddedItemsLabel(issue); this._statistics?.incrementAddedItemsLabel(issue);
if (!this.options.debugOnly) {
await this.client.issues.addLabels({ await this.client.issues.addLabels({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
labels: [closeLabel] labels: [closeLabel]
}); });
}
} catch (error) { } catch (error) {
issueLogger.error(`Error when adding a label: ${error.message}`); issueLogger.error(`Error when adding a label: ${error.message}`);
} }
@@ -798,12 +804,15 @@ export class IssuesProcessor {
try { try {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementClosedItemsCount(issue); this._statistics?.incrementClosedItemsCount(issue);
if (!this.options.debugOnly) {
await this.client.issues.update({ await this.client.issues.update({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: issue.number, issue_number: issue.number,
state: 'closed' state: 'closed'
}); });
}
} catch (error) { } catch (error) {
issueLogger.error(`Error when updating this $$type: ${error.message}`); issueLogger.error(`Error when updating this $$type: ${error.message}`);
} }
@@ -818,7 +827,6 @@ export class IssuesProcessor {
this._consumeIssueOperation(issue); this._consumeIssueOperation(issue);
this._statistics?.incrementFetchedPullRequestsCount(); this._statistics?.incrementFetchedPullRequestsCount();
if (!this.options.debugOnly) {
const pullRequest = await this.client.pulls.get({ const pullRequest = await this.client.pulls.get({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
@@ -826,7 +834,6 @@ export class IssuesProcessor {
}); });
return pullRequest.data; return pullRequest.data;
}
} catch (error) { } catch (error) {
issueLogger.error(`Error when getting this $$type: ${error.message}`); issueLogger.error(`Error when getting this $$type: ${error.message}`);
} }