mirror of
https://github.com/actions/stale.git
synced 2025-12-10 20:21:20 +00:00
Add state
This commit is contained in:
@@ -26,6 +26,7 @@ import {Statistics} from './statistics';
|
||||
import {LoggerService} from '../services/logger.service';
|
||||
import {OctokitIssue} from '../interfaces/issue';
|
||||
import {retry} from '@octokit/plugin-retry';
|
||||
import {IState} from '../interfaces/state';
|
||||
|
||||
/***
|
||||
* Handle processing of issues for staleness/closure.
|
||||
@@ -72,9 +73,11 @@ export class IssuesProcessor {
|
||||
readonly addedCloseCommentIssues: Issue[] = [];
|
||||
readonly statistics: Statistics | undefined;
|
||||
private readonly _logger: Logger = new Logger();
|
||||
private readonly state: IState;
|
||||
|
||||
constructor(options: IIssuesProcessorOptions) {
|
||||
constructor(options: IIssuesProcessorOptions, state: IState) {
|
||||
this.options = options;
|
||||
this.state = state;
|
||||
this.client = getOctokit(this.options.repoToken, undefined, retry);
|
||||
this.operations = new StaleOperations(this.options);
|
||||
|
||||
@@ -110,6 +113,8 @@ export class IssuesProcessor {
|
||||
?.setOperationsCount(this.operations.getConsumedOperationsCount())
|
||||
.logStats();
|
||||
|
||||
this.state.reset();
|
||||
|
||||
return this.operations.getRemainingOperationsCount();
|
||||
} else {
|
||||
this._logger.info(
|
||||
@@ -196,6 +201,15 @@ export class IssuesProcessor {
|
||||
)}`
|
||||
);
|
||||
|
||||
if (this.state.isIssueProcessed(issue)) {
|
||||
issueLogger.info(
|
||||
' $$type skipped due being processed during the previous run'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.state.addIssueToProcessed(issue);
|
||||
|
||||
// calculate string based messages for this issue
|
||||
const staleMessage: string = issue.isPullRequest
|
||||
? this.options.stalePrMessage
|
||||
|
||||
Reference in New Issue
Block a user