Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't process a stale issue in the same run it's marked stale #696

Merged
merged 1 commit into from Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion dist/index.js
Expand Up @@ -278,6 +278,7 @@ class Issue {
this.milestone = issue.milestone;
this.assignees = issue.assignees;
this.isStale = is_labeled_1.isLabeled(this, this.staleLabel);
this.markedStaleThisRun = false;
}
get isPullRequest() {
return is_pull_request_1.isPullRequest(this);
Expand Down Expand Up @@ -589,6 +590,7 @@ class IssuesProcessor {
issueLogger.info(`This $$type should be marked as stale based on the option ${issueLogger.createOptionLink(this._getDaysBeforeStaleUsedOptionName(issue))} (${logger_service_1.LoggerService.cyan(daysBeforeStale)})`);
yield this._markStale(issue, staleMessage, staleLabel, skipMessage);
issue.isStale = true; // This issue is now considered stale
issue.markedStaleThisRun = true;
issueLogger.info(`This $$type is now stale`);
}
else {
Expand Down Expand Up @@ -726,8 +728,13 @@ class IssuesProcessor {
else {
issueLogger.info(`The stale label should be removed if all conditions met`);
}
if (issue.markedStaleThisRun) {
issueLogger.info(`marked stale this run, so don't check for updates`);
}
// Should we un-stale this issue?
if (shouldRemoveStaleWhenUpdated && issueHasComments) {
if (shouldRemoveStaleWhenUpdated &&
issueHasComments &&
!issue.markedStaleThisRun) {
issueLogger.info(`Remove the stale label since the $$type has a comment and the workflow should remove the stale label when updated`);
yield this._removeStaleLabel(issue, staleLabel);
// Are there labels to remove or add when an issue is no longer stale?
Expand Down
2 changes: 2 additions & 0 deletions src/classes/issue.ts
Expand Up @@ -20,6 +20,7 @@ export class Issue implements IIssue {
readonly milestone: IMilestone | undefined;
readonly assignees: Assignee[];
isStale: boolean;
markedStaleThisRun: boolean;
operations = new Operations();
private readonly _options: IIssuesProcessorOptions;

Expand All @@ -39,6 +40,7 @@ export class Issue implements IIssue {
this.milestone = issue.milestone;
this.assignees = issue.assignees;
this.isStale = isLabeled(this, this.staleLabel);
this.markedStaleThisRun = false;
}

get isPullRequest(): boolean {
Expand Down
11 changes: 10 additions & 1 deletion src/classes/issues-processor.ts
Expand Up @@ -466,6 +466,7 @@ export class IssuesProcessor {
);
await this._markStale(issue, staleMessage, staleLabel, skipMessage);
issue.isStale = true; // This issue is now considered stale
issue.markedStaleThisRun = true;
issueLogger.info(`This $$type is now stale`);
} else {
issueLogger.info(
Expand Down Expand Up @@ -672,8 +673,16 @@ export class IssuesProcessor {
);
}

if (issue.markedStaleThisRun) {
issueLogger.info(`marked stale this run, so don't check for updates`);
}

// Should we un-stale this issue?
if (shouldRemoveStaleWhenUpdated && issueHasComments) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we could just else if here and remove !issue.markedStaleThisRun

shouldRemoveStaleWhenUpdated &&
issueHasComments &&
!issue.markedStaleThisRun
) {
issueLogger.info(
`Remove the stale label since the $$type has a comment and the workflow should remove the stale label when updated`
);
Expand Down