mirror of
https://github.com/actions/stale.git
synced 2025-12-10 20:21:20 +00:00
fix(remove-label): do not encode the label to make sure to remove it (#220)
* test: add two more tests relating the label syntax issues both are failing * chore: add more logs and fix the tests on error meaning that I did not find a reproduction... * chore: minor improvements with the types and logs * fix(remove-label): do not encode the label to make sure to remove it could lead to an issue since based on the comment it was here on purpose
This commit is contained in:
committed by
GitHub
parent
107018c400
commit
ddc7648635
@@ -1,5 +1,6 @@
|
||||
import * as core from '@actions/core';
|
||||
import {context, getOctokit} from '@actions/github';
|
||||
import {GitHub} from '@actions/github/lib/utils';
|
||||
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
|
||||
import {isLabeled} from './functions/is-labeled';
|
||||
import {labelsToList} from './functions/labels-to-list';
|
||||
@@ -68,7 +69,7 @@ export interface IssueProcessorOptions {
|
||||
* Handle processing of issues for staleness/closure.
|
||||
*/
|
||||
export class IssueProcessor {
|
||||
readonly client: any; // need to make this the correct type
|
||||
readonly client: InstanceType<typeof GitHub>;
|
||||
readonly options: IssueProcessorOptions;
|
||||
private operationsLeft = 0;
|
||||
|
||||
@@ -176,7 +177,13 @@ export class IssueProcessor {
|
||||
}
|
||||
|
||||
// does this issue have a stale label?
|
||||
let isStale = isLabeled(issue, staleLabel);
|
||||
let isStale: boolean = isLabeled(issue, staleLabel);
|
||||
|
||||
if (isStale) {
|
||||
core.info(`This issue has a stale label`);
|
||||
} else {
|
||||
core.info(`This issue hasn't a stale label`);
|
||||
}
|
||||
|
||||
// should this issue be marked stale?
|
||||
const shouldBeStale = !IssueProcessor.updatedSince(
|
||||
@@ -506,12 +513,13 @@ export class IssueProcessor {
|
||||
|
||||
// Remove a label from an issue
|
||||
private async removeLabel(issue: Issue, label: string): Promise<void> {
|
||||
core.info(`Removing label from issue #${issue.number}`);
|
||||
core.info(`Removing label "${label}" from issue #${issue.number}`);
|
||||
|
||||
this.removedLabelIssues.push(issue);
|
||||
|
||||
this.operationsLeft -= 1;
|
||||
|
||||
// @todo remove the debug only to be able to test the code below
|
||||
if (this.options.debugOnly) {
|
||||
return;
|
||||
}
|
||||
@@ -521,7 +529,7 @@ export class IssueProcessor {
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
name: encodeURIComponent(label) // A label can have a "?" in the name
|
||||
name: label
|
||||
});
|
||||
} catch (error) {
|
||||
core.error(`Error removing a label: ${error.message}`);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import deburr from 'lodash.deburr';
|
||||
import {Issue, Label} from '../IssueProcessor';
|
||||
|
||||
type CleanLabel = string;
|
||||
|
||||
/**
|
||||
* @description
|
||||
* Check if the label is listed as a label of the issue
|
||||
@@ -19,6 +21,6 @@ export function isLabeled(
|
||||
});
|
||||
}
|
||||
|
||||
function cleanLabel(label: Readonly<string>): string {
|
||||
function cleanLabel(label: Readonly<string>): CleanLabel {
|
||||
return deburr(label.toLowerCase());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user