mirror of
https://github.com/actions/stale.git
synced 2026-02-15 02:28:18 +00:00
Compare commits
3 Commits
dependabot
...
enhancemen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47c6b2cb49 | ||
|
|
dcd2b9469d | ||
|
|
d6f8a33132 |
@@ -10,7 +10,6 @@ allowed:
|
||||
- cc0-1.0
|
||||
- unlicense
|
||||
- 0bsd
|
||||
- blueoak-1.0.0
|
||||
|
||||
reviewed:
|
||||
npm:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/http-client"
|
||||
version: 2.2.3
|
||||
version: 2.2.0
|
||||
type: npm
|
||||
summary: Actions Http Client
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
|
||||
2
.licenses/npm/@fastify/busboy.dep.yml
generated
2
.licenses/npm/@fastify/busboy.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@fastify/busboy"
|
||||
version: 2.1.1
|
||||
version: 2.1.0
|
||||
type: npm
|
||||
summary: A streaming parser for HTML form data for node.js
|
||||
homepage:
|
||||
|
||||
2
.licenses/npm/@octokit/plugin-retry.dep.yml
generated
2
.licenses/npm/@octokit/plugin-retry.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@octokit/plugin-retry"
|
||||
version: 5.0.5
|
||||
version: 4.1.6
|
||||
type: npm
|
||||
summary: Automatic retry plugin for octokit
|
||||
homepage:
|
||||
|
||||
34
.licenses/npm/@octokit/request-error-4.0.2.dep.yml
generated
34
.licenses/npm/@octokit/request-error-4.0.2.dep.yml
generated
@@ -1,34 +0,0 @@
|
||||
---
|
||||
name: "@octokit/request-error"
|
||||
version: 4.0.2
|
||||
type: npm
|
||||
summary: Error class for Octokit request errors
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
- sources: README.md
|
||||
text: "[MIT](LICENSE)"
|
||||
notices: []
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@octokit/types"
|
||||
version: 10.0.0
|
||||
version: 9.3.2
|
||||
type: npm
|
||||
summary: Shared TypeScript definitions for Octokit projects
|
||||
homepage:
|
||||
2
.licenses/npm/debug.dep.yml
generated
2
.licenses/npm/debug.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: debug
|
||||
version: 4.4.3
|
||||
version: 4.3.4
|
||||
type: npm
|
||||
summary: Lightweight debugging utility for Node.js and the browser
|
||||
homepage:
|
||||
|
||||
4
.licenses/npm/ms.dep.yml
generated
4
.licenses/npm/ms.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: ms
|
||||
version: 2.1.3
|
||||
version: 2.1.2
|
||||
type: npm
|
||||
summary: Tiny millisecond conversion utility
|
||||
homepage:
|
||||
@@ -10,7 +10,7 @@ licenses:
|
||||
text: |
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Vercel, Inc.
|
||||
Copyright (c) 2016 Zeit, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: semver
|
||||
version: 7.7.3
|
||||
version: 7.6.3
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage:
|
||||
@@ -4,6 +4,7 @@ import {IComment} from '../../src/interfaces/comment';
|
||||
import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-options';
|
||||
import {IPullRequest} from '../../src/interfaces/pull-request';
|
||||
import {IState} from '../../src/interfaces/state/state';
|
||||
import {IIssueEvent} from '../../src/interfaces/issue-event';
|
||||
|
||||
export class IssuesProcessorMock extends IssuesProcessor {
|
||||
constructor(
|
||||
@@ -17,7 +18,15 @@ export class IssuesProcessorMock extends IssuesProcessor {
|
||||
getLabelCreationDate?: (
|
||||
issue: Issue,
|
||||
label: string
|
||||
) => Promise<string | undefined>,
|
||||
) =>
|
||||
| Promise<string | undefined>
|
||||
| Promise<{creationDate?: string; events: IIssueEvent[]}>,
|
||||
hasOnlyStaleLabelingEventsSince?: (
|
||||
issue: Issue,
|
||||
sinceDate: string,
|
||||
staleLabel: string,
|
||||
events: IIssueEvent[]
|
||||
) => Promise<boolean>,
|
||||
getPullRequest?: (issue: Issue) => Promise<IPullRequest | undefined | void>
|
||||
) {
|
||||
super(options, state);
|
||||
@@ -31,7 +40,21 @@ export class IssuesProcessorMock extends IssuesProcessor {
|
||||
}
|
||||
|
||||
if (getLabelCreationDate) {
|
||||
this.getLabelCreationDate = getLabelCreationDate;
|
||||
this.getLabelCreationDate = async (
|
||||
issue: Issue,
|
||||
label: string
|
||||
): Promise<{creationDate?: string; events: IIssueEvent[]}> => {
|
||||
const result = await getLabelCreationDate(issue, label);
|
||||
if (typeof result === 'string' || typeof result === 'undefined') {
|
||||
return {creationDate: result, events: []};
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
if (hasOnlyStaleLabelingEventsSince) {
|
||||
this.hasOnlyStaleLabelingEventsSince = hasOnlyStaleLabelingEventsSince;
|
||||
}
|
||||
|
||||
if (getPullRequest) {
|
||||
|
||||
@@ -129,6 +129,7 @@ class IssuesProcessorBuilder {
|
||||
async p => (p === 1 ? this._issues : []),
|
||||
async () => [],
|
||||
async () => new Date().toDateString(),
|
||||
undefined,
|
||||
async (): Promise<IPullRequest> => {
|
||||
return Promise.resolve({
|
||||
number: 0,
|
||||
|
||||
288
__tests__/remove-stale-when-updated-label-events.spec.ts
Normal file
288
__tests__/remove-stale-when-updated-label-events.spec.ts
Normal file
@@ -0,0 +1,288 @@
|
||||
import {Issue} from '../src/classes/issue';
|
||||
import {IIssuesProcessorOptions} from '../src/interfaces/issues-processor-options';
|
||||
import {IssuesProcessorMock} from './classes/issues-processor-mock';
|
||||
import {DefaultProcessorOptions} from './constants/default-processor-options';
|
||||
import {generateIssue} from './functions/generate-issue';
|
||||
import {alwaysFalseStateMock} from './classes/state-mock';
|
||||
import {IState} from '../src/interfaces/state/state';
|
||||
import {IIssueEvent} from '../src/interfaces/issue-event';
|
||||
import {IssuesProcessor} from '../src/classes/issues-processor';
|
||||
|
||||
describe('remove-stale-when-updated with stale label events', (): void => {
|
||||
const markedStaleOn = '2025-01-01T00:00:00Z';
|
||||
const updatedAt = '2025-01-01T00:01:00Z';
|
||||
|
||||
let options: IIssuesProcessorOptions;
|
||||
|
||||
beforeEach((): void => {
|
||||
options = {
|
||||
...DefaultProcessorOptions,
|
||||
removeStaleWhenUpdated: true
|
||||
};
|
||||
});
|
||||
|
||||
const buildIssue = (): Issue =>
|
||||
generateIssue(
|
||||
options,
|
||||
1,
|
||||
'dummy-title',
|
||||
updatedAt,
|
||||
markedStaleOn,
|
||||
false,
|
||||
false,
|
||||
['Stale']
|
||||
);
|
||||
|
||||
const buildEvents = (): IIssueEvent[] => [
|
||||
{
|
||||
event: 'labeled',
|
||||
created_at: markedStaleOn,
|
||||
label: {name: 'Stale'}
|
||||
}
|
||||
];
|
||||
|
||||
test('does not remove stale label when only stale label events occurred', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
|
||||
const processor = new IssuesProcessorMock(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
async p => (p === 1 ? [issue] : []),
|
||||
async () => [],
|
||||
async () => ({creationDate: markedStaleOn, events: buildEvents()}),
|
||||
async () => true
|
||||
);
|
||||
|
||||
await processor.processIssues();
|
||||
|
||||
expect(processor.removedLabelIssues).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('removes stale label when updates are not just stale label events', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
|
||||
const processor = new IssuesProcessorMock(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
async p => (p === 1 ? [issue] : []),
|
||||
async () => [],
|
||||
async () => ({creationDate: markedStaleOn, events: buildEvents()}),
|
||||
async () => false
|
||||
);
|
||||
|
||||
await processor.processIssues();
|
||||
|
||||
expect(processor.removedLabelIssues).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
class TestIssuesProcessor extends IssuesProcessor {
|
||||
constructor(
|
||||
options: IIssuesProcessorOptions,
|
||||
state: IState,
|
||||
events: IIssueEvent[]
|
||||
) {
|
||||
super(options, state);
|
||||
const client = {
|
||||
rest: {
|
||||
issues: {
|
||||
listEvents: {
|
||||
endpoint: {
|
||||
merge: () => ({})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
paginate: {
|
||||
iterator: async function* () {
|
||||
yield {data: events};
|
||||
}
|
||||
}
|
||||
};
|
||||
(this as any).client = client;
|
||||
}
|
||||
|
||||
async callhasOnlyStaleLabelingEventsSince(
|
||||
issue: Issue,
|
||||
sinceDate: string,
|
||||
staleLabel: string,
|
||||
events: IIssueEvent[]
|
||||
): Promise<boolean> {
|
||||
return this.hasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
sinceDate,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
describe('hasOnlyStaleLabelingEventsSince', (): void => {
|
||||
const staleLabel = 'Stale';
|
||||
const sinceDate = '2025-01-01T00:00:00Z';
|
||||
const originalRepo = process.env.GITHUB_REPOSITORY;
|
||||
|
||||
let options: IIssuesProcessorOptions;
|
||||
|
||||
beforeEach((): void => {
|
||||
process.env.GITHUB_REPOSITORY = 'owner/repo';
|
||||
options = {
|
||||
...DefaultProcessorOptions,
|
||||
staleIssueLabel: staleLabel,
|
||||
removeStaleWhenUpdated: true
|
||||
};
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
if (originalRepo === undefined) {
|
||||
delete process.env.GITHUB_REPOSITORY;
|
||||
} else {
|
||||
process.env.GITHUB_REPOSITORY = originalRepo;
|
||||
}
|
||||
});
|
||||
|
||||
const buildIssue = (): Issue =>
|
||||
generateIssue(
|
||||
options,
|
||||
1,
|
||||
'dummy-title',
|
||||
'2025-01-01T00:02:00Z',
|
||||
sinceDate,
|
||||
false,
|
||||
false,
|
||||
[staleLabel]
|
||||
);
|
||||
|
||||
test('returns true when only stale label events exist after the since date', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
const events: IIssueEvent[] = [
|
||||
// Event before the sinceDate should be ignored.
|
||||
{
|
||||
event: 'labeled',
|
||||
created_at: '2024-12-31T23:59:00Z',
|
||||
label: {name: staleLabel}
|
||||
},
|
||||
{
|
||||
event: 'labeled',
|
||||
created_at: '2025-01-01T00:00:10Z',
|
||||
label: {name: staleLabel}
|
||||
}
|
||||
];
|
||||
const processor = new TestIssuesProcessor(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
events
|
||||
);
|
||||
const result = await processor.callhasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
sinceDate,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
test('returns false when a non-stale label event exists after the since date', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
const events: IIssueEvent[] = [
|
||||
{
|
||||
event: 'labeled',
|
||||
created_at: '2025-01-01T00:00:10Z',
|
||||
label: {name: 'other-label'}
|
||||
}
|
||||
];
|
||||
const processor = new TestIssuesProcessor(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
events
|
||||
);
|
||||
const result = await processor.callhasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
sinceDate,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
test('returns false when stale label is removed after the since date', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
const events: IIssueEvent[] = [
|
||||
{
|
||||
event: 'unlabeled',
|
||||
created_at: '2025-01-01T00:00:10Z',
|
||||
label: {name: staleLabel}
|
||||
}
|
||||
];
|
||||
const processor = new TestIssuesProcessor(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
events
|
||||
);
|
||||
const result = await processor.callhasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
sinceDate,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
test('returns false when a non-label event exists after the since date', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
const events: IIssueEvent[] = [
|
||||
{
|
||||
event: 'commented',
|
||||
created_at: '2025-01-01T00:00:10Z',
|
||||
label: {name: staleLabel}
|
||||
}
|
||||
];
|
||||
const processor = new TestIssuesProcessor(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
events
|
||||
);
|
||||
const result = await processor.callhasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
sinceDate,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
test('includes events that occur exactly at the since date boundary', async (): Promise<void> => {
|
||||
expect.assertions(1);
|
||||
const issue = buildIssue();
|
||||
const events: IIssueEvent[] = [
|
||||
{
|
||||
event: 'labeled',
|
||||
created_at: sinceDate,
|
||||
label: {name: staleLabel}
|
||||
}
|
||||
];
|
||||
const processor = new TestIssuesProcessor(
|
||||
options,
|
||||
alwaysFalseStateMock,
|
||||
events
|
||||
);
|
||||
const result = await processor.callhasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
sinceDate,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
496
dist/index.js
vendored
496
dist/index.js
vendored
@@ -172,8 +172,8 @@ class ExemptDraftPullRequest {
|
||||
// keep this for backward compatibility
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
pullRequestCallback) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
if (this._issue.isPullRequest) {
|
||||
if (this._options.exemptDraftPr) {
|
||||
this._issueLogger.info(`The option ${this._issueLogger.createOptionLink(option_1.Option.ExemptDraftPr)} is enabled`);
|
||||
@@ -348,23 +348,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -440,9 +430,9 @@ class IssuesProcessor {
|
||||
this.statistics = new statistics_1.Statistics();
|
||||
}
|
||||
}
|
||||
processIssues() {
|
||||
return __awaiter(this, arguments, void 0, function* (page = 1) {
|
||||
var _a, _b;
|
||||
processIssues(page = 1) {
|
||||
var _a, _b;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// get the next batch of issues
|
||||
const issues = yield this.getIssues(page);
|
||||
if (issues.length <= 0) {
|
||||
@@ -484,8 +474,8 @@ class IssuesProcessor {
|
||||
});
|
||||
}
|
||||
processIssue(issue, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, labelsToRemoveWhenStale) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementProcessedItemsCount(issue);
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`Found this $$type last updated at: ${logger_service_1.LoggerService.cyan(issue.updated_at)}`);
|
||||
@@ -682,8 +672,8 @@ class IssuesProcessor {
|
||||
}
|
||||
// Grab comments for an issue since a given date
|
||||
listIssueComments(issue, sinceDate) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
// Find any comments since date on the given issue
|
||||
try {
|
||||
this._consumeIssueOperation(issue);
|
||||
@@ -704,8 +694,8 @@ class IssuesProcessor {
|
||||
}
|
||||
// grab issues from github in batches of 100
|
||||
getIssues(page) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
try {
|
||||
this.operations.consumeOperation();
|
||||
const issueResult = yield this.client.rest.issues.listForRepo({
|
||||
@@ -728,8 +718,8 @@ class IssuesProcessor {
|
||||
// returns the creation date of a given label on an issue (or nothing if no label existed)
|
||||
///see https://developer.github.com/v3/activity/events/
|
||||
getLabelCreationDate(issue, label) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`Checking for label on this $$type`);
|
||||
this._consumeIssueOperation(issue);
|
||||
@@ -746,14 +736,40 @@ class IssuesProcessor {
|
||||
(0, clean_label_1.cleanLabel)(event.label.name) === (0, clean_label_1.cleanLabel)(label));
|
||||
if (!staleLabeledEvent) {
|
||||
// Must be old rather than labeled
|
||||
return undefined;
|
||||
return { creationDate: undefined, events };
|
||||
}
|
||||
return staleLabeledEvent.created_at;
|
||||
return { creationDate: staleLabeledEvent.created_at, events };
|
||||
});
|
||||
}
|
||||
hasOnlyStaleLabelingEventsSince(issue, sinceDate, staleLabel, events) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`Checking if only stale label added events on $$type since: ${logger_service_1.LoggerService.cyan(sinceDate)}`);
|
||||
if (!sinceDate) {
|
||||
return false;
|
||||
}
|
||||
const sinceTimestamp = new Date(sinceDate).getTime();
|
||||
if (Number.isNaN(sinceTimestamp)) {
|
||||
return false;
|
||||
}
|
||||
const relevantEvents = events.filter(event => {
|
||||
const eventTimestamp = new Date(event.created_at).getTime();
|
||||
return !Number.isNaN(eventTimestamp) && eventTimestamp >= sinceTimestamp;
|
||||
});
|
||||
if (relevantEvents.length === 0) {
|
||||
return false;
|
||||
}
|
||||
return relevantEvents.every(event => {
|
||||
if (event.event !== 'labeled') {
|
||||
return false;
|
||||
}
|
||||
return (0, clean_label_1.cleanLabel)(event.label.name) === (0, clean_label_1.cleanLabel)(staleLabel);
|
||||
});
|
||||
});
|
||||
}
|
||||
getPullRequest(issue) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
try {
|
||||
this._consumeIssueOperation(issue);
|
||||
@@ -771,8 +787,8 @@ class IssuesProcessor {
|
||||
});
|
||||
}
|
||||
getRateLimit() {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const logger = new logger_1.Logger();
|
||||
try {
|
||||
const rateLimitResult = yield this.client.rest.rateLimit.get();
|
||||
@@ -793,7 +809,8 @@ class IssuesProcessor {
|
||||
_processStaleIssue(issue, staleLabel, staleMessage, labelsToAddWhenUnstale, labelsToRemoveWhenUnstale, labelsToRemoveWhenStale, closeMessage, closeLabel) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
const markedStaleOn = (yield this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
||||
const { creationDate, events } = yield this.getLabelCreationDate(issue, staleLabel);
|
||||
const markedStaleOn = creationDate || issue.updated_at;
|
||||
issueLogger.info(`$$type marked stale on: ${logger_service_1.LoggerService.cyan(markedStaleOn)}`);
|
||||
const issueHasCommentsSinceStale = yield this._hasCommentsSince(issue, markedStaleOn, staleMessage);
|
||||
issueLogger.info(`$$type has been commented on: ${logger_service_1.LoggerService.cyan(issueHasCommentsSinceStale)}`);
|
||||
@@ -815,7 +832,17 @@ class IssuesProcessor {
|
||||
}
|
||||
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
||||
// isDateMoreRecentThan makes sure they are not the same date within a certain tolerance (15 seconds in this case)
|
||||
const issueHasUpdateSinceStale = (0, is_date_more_recent_than_1.isDateMoreRecentThan)(new Date(issue.updated_at), new Date(markedStaleOn), 15);
|
||||
let issueHasUpdateSinceStale = (0, is_date_more_recent_than_1.isDateMoreRecentThan)(new Date(issue.updated_at), new Date(markedStaleOn), 15);
|
||||
// Check if the only update was the stale label being added
|
||||
if (issueHasUpdateSinceStale &&
|
||||
shouldRemoveStaleWhenUpdated &&
|
||||
!issue.markedStaleThisRun) {
|
||||
const onlyStaleLabelAdded = yield this.hasOnlyStaleLabelingEventsSince(issue, markedStaleOn, staleLabel, events);
|
||||
if (onlyStaleLabelAdded) {
|
||||
issueHasUpdateSinceStale = false;
|
||||
issueLogger.info(`Ignoring $$type update since only the stale label was added`);
|
||||
}
|
||||
}
|
||||
issueLogger.info(`$$type has been updated since it was marked stale: ${logger_service_1.LoggerService.cyan(issueHasUpdateSinceStale)}`);
|
||||
// Should we un-stale this issue?
|
||||
if (shouldRemoveStaleWhenUpdated &&
|
||||
@@ -871,8 +898,8 @@ class IssuesProcessor {
|
||||
}
|
||||
// Mark an issue as stale with a comment and a label
|
||||
_markStale(issue, staleMessage, staleLabel, skipMessage) {
|
||||
var _a, _b, _c;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a, _b, _c;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`Marking this $$type as stale`);
|
||||
this.staleIssues.push(issue);
|
||||
@@ -917,8 +944,8 @@ class IssuesProcessor {
|
||||
}
|
||||
// Close an issue based on staleness
|
||||
_closeIssue(issue, closeMessage, closeLabel) {
|
||||
var _a, _b, _c;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a, _b, _c;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`Closing $$type for being stale`);
|
||||
this.closedIssues.push(issue);
|
||||
@@ -977,8 +1004,8 @@ class IssuesProcessor {
|
||||
}
|
||||
// Delete the branch on closed pull request
|
||||
_deleteBranch(issue) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`Delete
|
||||
branch from closed $
|
||||
@@ -1016,9 +1043,9 @@ class IssuesProcessor {
|
||||
});
|
||||
}
|
||||
// Remove a label from an issue or a pull request
|
||||
_removeLabel(issue_2, label_1) {
|
||||
return __awaiter(this, arguments, void 0, function* (issue, label, isSubStep = false) {
|
||||
var _a;
|
||||
_removeLabel(issue, label, isSubStep = false) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`${isSubStep ? logger_service_1.LoggerService.white('├── ') : ''}Removing the label "${logger_service_1.LoggerService.cyan(label)}" from this $$type...`);
|
||||
this.removedLabelIssues.push(issue);
|
||||
@@ -1114,8 +1141,8 @@ class IssuesProcessor {
|
||||
});
|
||||
}
|
||||
_addLabelsWhenUnstale(issue, labelsToAdd) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
if (!labelsToAdd.length) {
|
||||
return;
|
||||
}
|
||||
@@ -1140,8 +1167,8 @@ class IssuesProcessor {
|
||||
});
|
||||
}
|
||||
_removeStaleLabel(issue, staleLabel) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`The $$type is no longer stale. Removing the stale label...`);
|
||||
yield this._removeLabel(issue, staleLabel);
|
||||
@@ -1149,8 +1176,8 @@ class IssuesProcessor {
|
||||
});
|
||||
}
|
||||
_removeCloseLabel(issue, closeLabel) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const issueLogger = new issue_logger_1.IssueLogger(issue);
|
||||
issueLogger.info(`The $$type is not closed nor locked. Trying to remove the close label...`);
|
||||
if (!closeLabel) {
|
||||
@@ -1314,23 +1341,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -1615,23 +1632,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -1787,23 +1794,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -2313,7 +2310,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.cleanLabel = cleanLabel;
|
||||
exports.cleanLabel = void 0;
|
||||
const lodash_deburr_1 = __importDefault(__nccwpck_require__(61601));
|
||||
/**
|
||||
* @description
|
||||
@@ -2326,6 +2323,7 @@ const lodash_deburr_1 = __importDefault(__nccwpck_require__(61601));
|
||||
function cleanLabel(label) {
|
||||
return (0, lodash_deburr_1.default)(label === null || label === void 0 ? void 0 : label.toLowerCase());
|
||||
}
|
||||
exports.cleanLabel = cleanLabel;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2336,7 +2334,7 @@ function cleanLabel(label) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getHumanizedDate = getHumanizedDate;
|
||||
exports.getHumanizedDate = void 0;
|
||||
function getHumanizedDate(date) {
|
||||
const year = date.getFullYear();
|
||||
let month = `${date.getMonth() + 1}`;
|
||||
@@ -2349,6 +2347,7 @@ function getHumanizedDate(date) {
|
||||
}
|
||||
return [day, month, year].join('-');
|
||||
}
|
||||
exports.getHumanizedDate = getHumanizedDate;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2361,8 +2360,7 @@ function getHumanizedDate(date) {
|
||||
/// returns false if the dates are equal within the `equalityToleranceInSeconds` number of seconds
|
||||
/// otherwise returns true if `comparedDate` is after `date`
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isDateMoreRecentThan = isDateMoreRecentThan;
|
||||
exports.isDateEqualTo = isDateEqualTo;
|
||||
exports.isDateEqualTo = exports.isDateMoreRecentThan = void 0;
|
||||
function isDateMoreRecentThan(date, comparedDate, equalityToleranceInSeconds = 0) {
|
||||
if (equalityToleranceInSeconds > 0) {
|
||||
const areDatesEqual = isDateEqualTo(date, comparedDate, equalityToleranceInSeconds);
|
||||
@@ -2370,12 +2368,14 @@ function isDateMoreRecentThan(date, comparedDate, equalityToleranceInSeconds = 0
|
||||
}
|
||||
return date > comparedDate;
|
||||
}
|
||||
exports.isDateMoreRecentThan = isDateMoreRecentThan;
|
||||
function isDateEqualTo(date, otherDate, toleranceInSeconds) {
|
||||
const timestamp = date.getTime();
|
||||
const otherTimestamp = otherDate.getTime();
|
||||
const deltaInSeconds = Math.abs(timestamp - otherTimestamp) / 1000;
|
||||
return deltaInSeconds <= toleranceInSeconds;
|
||||
}
|
||||
exports.isDateEqualTo = isDateEqualTo;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2386,7 +2386,7 @@ function isDateEqualTo(date, otherDate, toleranceInSeconds) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isValidDate = isValidDate;
|
||||
exports.isValidDate = void 0;
|
||||
/**
|
||||
* @description
|
||||
* Check if a date is valid
|
||||
@@ -2404,6 +2404,7 @@ function isValidDate(date) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isValidDate = isValidDate;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2414,7 +2415,7 @@ function isValidDate(date) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getSortField = getSortField;
|
||||
exports.getSortField = void 0;
|
||||
function getSortField(sortOption) {
|
||||
return sortOption === 'updated'
|
||||
? 'updated'
|
||||
@@ -2422,6 +2423,7 @@ function getSortField(sortOption) {
|
||||
? 'comments'
|
||||
: 'created';
|
||||
}
|
||||
exports.getSortField = getSortField;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2432,10 +2434,11 @@ function getSortField(sortOption) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isBoolean = isBoolean;
|
||||
exports.isBoolean = void 0;
|
||||
function isBoolean(value) {
|
||||
return value === true || value === false;
|
||||
}
|
||||
exports.isBoolean = isBoolean;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2446,7 +2449,7 @@ function isBoolean(value) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isLabeled = isLabeled;
|
||||
exports.isLabeled = void 0;
|
||||
const clean_label_1 = __nccwpck_require__(67752);
|
||||
/**
|
||||
* @description
|
||||
@@ -2462,6 +2465,7 @@ function isLabeled(issue, label) {
|
||||
return (0, clean_label_1.cleanLabel)(label) === (0, clean_label_1.cleanLabel)(issueLabel.name);
|
||||
});
|
||||
}
|
||||
exports.isLabeled = isLabeled;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2472,10 +2476,11 @@ function isLabeled(issue, label) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.isPullRequest = isPullRequest;
|
||||
exports.isPullRequest = void 0;
|
||||
function isPullRequest(issue) {
|
||||
return !!issue.pull_request;
|
||||
}
|
||||
exports.isPullRequest = isPullRequest;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2486,10 +2491,11 @@ function isPullRequest(issue) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.shouldMarkWhenStale = shouldMarkWhenStale;
|
||||
exports.shouldMarkWhenStale = void 0;
|
||||
function shouldMarkWhenStale(daysBeforeStale) {
|
||||
return daysBeforeStale >= 0;
|
||||
}
|
||||
exports.shouldMarkWhenStale = shouldMarkWhenStale;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2500,7 +2506,7 @@ function shouldMarkWhenStale(daysBeforeStale) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.wordsToList = wordsToList;
|
||||
exports.wordsToList = void 0;
|
||||
/**
|
||||
* @description
|
||||
* Transform a string of comma separated words
|
||||
@@ -2523,6 +2529,7 @@ function wordsToList(words) {
|
||||
}
|
||||
return words.split(',').map((word) => word.trim());
|
||||
}
|
||||
exports.wordsToList = wordsToList;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -2548,23 +2555,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
@@ -15958,7 +15955,7 @@ class HttpClient {
|
||||
if (this._keepAlive && useProxy) {
|
||||
agent = this._proxyAgent;
|
||||
}
|
||||
if (!useProxy) {
|
||||
if (this._keepAlive && !useProxy) {
|
||||
agent = this._agent;
|
||||
}
|
||||
// if agent is already assigned use that agent.
|
||||
@@ -15990,12 +15987,16 @@ class HttpClient {
|
||||
agent = tunnelAgent(agentOptions);
|
||||
this._proxyAgent = agent;
|
||||
}
|
||||
// if tunneling agent isn't assigned create a new agent
|
||||
if (!agent) {
|
||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||
if (this._keepAlive && !agent) {
|
||||
const options = { keepAlive: this._keepAlive, maxSockets };
|
||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||
this._agent = agent;
|
||||
}
|
||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
||||
if (!agent) {
|
||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
||||
}
|
||||
if (usingSsl && this._ignoreSslError) {
|
||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||
@@ -16017,7 +16018,7 @@ class HttpClient {
|
||||
}
|
||||
const usingSsl = parsedUrl.protocol === 'https:';
|
||||
proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, ((proxyUrl.username || proxyUrl.password) && {
|
||||
token: `Basic ${Buffer.from(`${proxyUrl.username}:${proxyUrl.password}`).toString('base64')}`
|
||||
token: `${proxyUrl.username}:${proxyUrl.password}`
|
||||
})));
|
||||
this._proxyAgentDispatcher = proxyAgent;
|
||||
if (usingSsl && this._ignoreSslError) {
|
||||
@@ -16131,11 +16132,11 @@ function getProxyUrl(reqUrl) {
|
||||
})();
|
||||
if (proxyVar) {
|
||||
try {
|
||||
return new DecodedURL(proxyVar);
|
||||
return new URL(proxyVar);
|
||||
}
|
||||
catch (_a) {
|
||||
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
|
||||
return new DecodedURL(`http://${proxyVar}`);
|
||||
return new URL(`http://${proxyVar}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -16194,19 +16195,6 @@ function isLoopbackAddress(host) {
|
||||
hostLower.startsWith('[::1]') ||
|
||||
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
|
||||
}
|
||||
class DecodedURL extends URL {
|
||||
constructor(url, base) {
|
||||
super(url, base);
|
||||
this._decodedUsername = decodeURIComponent(super.username);
|
||||
this._decodedPassword = decodeURIComponent(super.password);
|
||||
}
|
||||
get username() {
|
||||
return this._decodedUsername;
|
||||
}
|
||||
get password() {
|
||||
return this._decodedPassword;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=proxy.js.map
|
||||
|
||||
/***/ }),
|
||||
@@ -20360,7 +20348,6 @@ __export(dist_src_exports, {
|
||||
retry: () => retry
|
||||
});
|
||||
module.exports = __toCommonJS(dist_src_exports);
|
||||
var import_core = __nccwpck_require__(76762);
|
||||
|
||||
// pkg/dist-src/error-request.js
|
||||
async function errorRequest(state, octokit, error, options) {
|
||||
@@ -20377,7 +20364,7 @@ async function errorRequest(state, octokit, error, options) {
|
||||
|
||||
// pkg/dist-src/wrap-request.js
|
||||
var import_light = __toESM(__nccwpck_require__(11174));
|
||||
var import_request_error = __nccwpck_require__(68036);
|
||||
var import_request_error = __nccwpck_require__(10537);
|
||||
async function wrapRequest(state, octokit, request, options) {
|
||||
const limiter = new import_light.default();
|
||||
limiter.on("failed", function(error, info) {
|
||||
@@ -20408,13 +20395,13 @@ async function requestWithGraphqlErrorHandling(state, octokit, request, options)
|
||||
}
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var VERSION = "5.0.5";
|
||||
var VERSION = "4.1.6";
|
||||
function retry(octokit, octokitOptions) {
|
||||
const state = Object.assign(
|
||||
{
|
||||
enabled: true,
|
||||
retryAfterBaseValue: 1e3,
|
||||
doNotRetry: [400, 401, 403, 404, 422, 451],
|
||||
doNotRetry: [400, 401, 403, 404, 422],
|
||||
retries: 3
|
||||
},
|
||||
octokitOptions.retry
|
||||
@@ -20440,104 +20427,6 @@ retry.VERSION = VERSION;
|
||||
0 && (0);
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 68036:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// pkg/dist-src/index.js
|
||||
var dist_src_exports = {};
|
||||
__export(dist_src_exports, {
|
||||
RequestError: () => RequestError
|
||||
});
|
||||
module.exports = __toCommonJS(dist_src_exports);
|
||||
var import_deprecation = __nccwpck_require__(58932);
|
||||
var import_once = __toESM(__nccwpck_require__(1223));
|
||||
var logOnceCode = (0, import_once.default)((deprecation) => console.warn(deprecation));
|
||||
var logOnceHeaders = (0, import_once.default)((deprecation) => console.warn(deprecation));
|
||||
var RequestError = class extends Error {
|
||||
constructor(message, statusCode, options) {
|
||||
super(message);
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
this.name = "HttpError";
|
||||
this.status = statusCode;
|
||||
let headers;
|
||||
if ("headers" in options && typeof options.headers !== "undefined") {
|
||||
headers = options.headers;
|
||||
}
|
||||
if ("response" in options) {
|
||||
this.response = options.response;
|
||||
headers = options.response.headers;
|
||||
}
|
||||
const requestCopy = Object.assign({}, options.request);
|
||||
if (options.request.headers.authorization) {
|
||||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||||
authorization: options.request.headers.authorization.replace(
|
||||
/ .*$/,
|
||||
" [REDACTED]"
|
||||
)
|
||||
});
|
||||
}
|
||||
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||||
this.request = requestCopy;
|
||||
Object.defineProperty(this, "code", {
|
||||
get() {
|
||||
logOnceCode(
|
||||
new import_deprecation.Deprecation(
|
||||
"[@octokit/request-error] `error.code` is deprecated, use `error.status`."
|
||||
)
|
||||
);
|
||||
return statusCode;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(this, "headers", {
|
||||
get() {
|
||||
logOnceHeaders(
|
||||
new import_deprecation.Deprecation(
|
||||
"[@octokit/request-error] `error.headers` is deprecated, use `error.response.headers`."
|
||||
)
|
||||
);
|
||||
return headers || {};
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (0);
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 10537:
|
||||
@@ -28541,17 +28430,14 @@ function useColors() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let m;
|
||||
|
||||
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||||
// eslint-disable-next-line no-return-assign
|
||||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
||||
// Is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
||||
// Is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
|
||||
// Double check webkit in userAgent just in case we are in a worker
|
||||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
||||
}
|
||||
@@ -28635,7 +28521,7 @@ function save(namespaces) {
|
||||
function load() {
|
||||
let r;
|
||||
try {
|
||||
r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
|
||||
r = exports.storage.getItem('debug');
|
||||
} catch (error) {
|
||||
// Swallow
|
||||
// XXX (@Qix-) should we be logging these?
|
||||
@@ -28861,64 +28747,26 @@ function setup(env) {
|
||||
createDebug.names = [];
|
||||
createDebug.skips = [];
|
||||
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '')
|
||||
.trim()
|
||||
.replace(/\s+/g, ',')
|
||||
.split(',')
|
||||
.filter(Boolean);
|
||||
let i;
|
||||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||||
const len = split.length;
|
||||
|
||||
for (const ns of split) {
|
||||
if (ns[0] === '-') {
|
||||
createDebug.skips.push(ns.slice(1));
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!split[i]) {
|
||||
// ignore empty strings
|
||||
continue;
|
||||
}
|
||||
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
|
||||
if (namespaces[0] === '-') {
|
||||
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
||||
} else {
|
||||
createDebug.names.push(ns);
|
||||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given string matches a namespace template, honoring
|
||||
* asterisks as wildcards.
|
||||
*
|
||||
* @param {String} search
|
||||
* @param {String} template
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function matchesTemplate(search, template) {
|
||||
let searchIndex = 0;
|
||||
let templateIndex = 0;
|
||||
let starIndex = -1;
|
||||
let matchIndex = 0;
|
||||
|
||||
while (searchIndex < search.length) {
|
||||
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
||||
// Match character or proceed with wildcard
|
||||
if (template[templateIndex] === '*') {
|
||||
starIndex = templateIndex;
|
||||
matchIndex = searchIndex;
|
||||
templateIndex++; // Skip the '*'
|
||||
} else {
|
||||
searchIndex++;
|
||||
templateIndex++;
|
||||
}
|
||||
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
||||
// Backtrack to the last '*' and try to match more characters
|
||||
templateIndex = starIndex + 1;
|
||||
matchIndex++;
|
||||
searchIndex = matchIndex;
|
||||
} else {
|
||||
return false; // No match
|
||||
}
|
||||
}
|
||||
|
||||
// Handle trailing '*' in template
|
||||
while (templateIndex < template.length && template[templateIndex] === '*') {
|
||||
templateIndex++;
|
||||
}
|
||||
|
||||
return templateIndex === template.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
@@ -28927,8 +28775,8 @@ function setup(env) {
|
||||
*/
|
||||
function disable() {
|
||||
const namespaces = [
|
||||
...createDebug.names,
|
||||
...createDebug.skips.map(namespace => '-' + namespace)
|
||||
...createDebug.names.map(toNamespace),
|
||||
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
|
||||
].join(',');
|
||||
createDebug.enable('');
|
||||
return namespaces;
|
||||
@@ -28942,14 +28790,21 @@ function setup(env) {
|
||||
* @api public
|
||||
*/
|
||||
function enabled(name) {
|
||||
for (const skip of createDebug.skips) {
|
||||
if (matchesTemplate(name, skip)) {
|
||||
if (name[name.length - 1] === '*') {
|
||||
return true;
|
||||
}
|
||||
|
||||
let i;
|
||||
let len;
|
||||
|
||||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||||
if (createDebug.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const ns of createDebug.names) {
|
||||
if (matchesTemplate(name, ns)) {
|
||||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||||
if (createDebug.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -28957,6 +28812,19 @@ function setup(env) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert regexp to namespace
|
||||
*
|
||||
* @param {RegExp} regxep
|
||||
* @return {String} namespace
|
||||
* @api private
|
||||
*/
|
||||
function toNamespace(regexp) {
|
||||
return regexp.toString()
|
||||
.substring(2, regexp.toString().length - 2)
|
||||
.replace(/\.\*\?$/, '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
@@ -29198,11 +29066,11 @@ function getDate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
||||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||||
*/
|
||||
|
||||
function log(...args) {
|
||||
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
||||
return process.stderr.write(util.format(...args) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -31016,7 +30884,7 @@ var y = d * 365.25;
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function (val, options) {
|
||||
module.exports = function(val, options) {
|
||||
options = options || {};
|
||||
var type = typeof val;
|
||||
if (type === 'string' && val.length > 0) {
|
||||
@@ -90358,7 +90226,7 @@ Dicer.prototype._write = function (data, encoding, cb) {
|
||||
if (this._headerFirst && this._isPreamble) {
|
||||
if (!this._part) {
|
||||
this._part = new PartStream(this._partOpts)
|
||||
if (this.listenerCount('preamble') !== 0) { this.emit('preamble', this._part) } else { this._ignore() }
|
||||
if (this._events.preamble) { this.emit('preamble', this._part) } else { this._ignore() }
|
||||
}
|
||||
const r = this._hparser.push(data)
|
||||
if (!this._inHeader && r !== undefined && r < data.length) { data = data.slice(r) } else { return cb() }
|
||||
@@ -90415,7 +90283,7 @@ Dicer.prototype._oninfo = function (isMatch, data, start, end) {
|
||||
}
|
||||
}
|
||||
if (this._dashes === 2) {
|
||||
if ((start + i) < end && this.listenerCount('trailer') !== 0) { this.emit('trailer', data.slice(start + i, end)) }
|
||||
if ((start + i) < end && this._events.trailer) { this.emit('trailer', data.slice(start + i, end)) }
|
||||
this.reset()
|
||||
this._finished = true
|
||||
// no more parts will be added
|
||||
@@ -90433,13 +90301,7 @@ Dicer.prototype._oninfo = function (isMatch, data, start, end) {
|
||||
this._part._read = function (n) {
|
||||
self._unpause()
|
||||
}
|
||||
if (this._isPreamble && this.listenerCount('preamble') !== 0) {
|
||||
this.emit('preamble', this._part)
|
||||
} else if (this._isPreamble !== true && this.listenerCount('part') !== 0) {
|
||||
this.emit('part', this._part)
|
||||
} else {
|
||||
this._ignore()
|
||||
}
|
||||
if (this._isPreamble && this._events.preamble) { this.emit('preamble', this._part) } else if (this._isPreamble !== true && this._events.part) { this.emit('part', this._part) } else { this._ignore() }
|
||||
if (!this._isPreamble) { this._inHeader = true }
|
||||
}
|
||||
if (data && start < end && !this._ignoreData) {
|
||||
@@ -91122,7 +90984,7 @@ function Multipart (boy, cfg) {
|
||||
|
||||
++nfiles
|
||||
|
||||
if (boy.listenerCount('file') === 0) {
|
||||
if (!boy._events.file) {
|
||||
self.parser._ignore()
|
||||
return
|
||||
}
|
||||
@@ -91651,7 +91513,7 @@ const decoders = {
|
||||
if (textDecoders.has(this.toString())) {
|
||||
try {
|
||||
return textDecoders.get(this).decode(data)
|
||||
} catch {}
|
||||
} catch (e) { }
|
||||
}
|
||||
return typeof data === 'string'
|
||||
? data
|
||||
|
||||
1946
package-lock.json
generated
1946
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -41,7 +41,7 @@
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/github": "^7.0.0",
|
||||
"@octokit/core": "^5.2.0",
|
||||
"@octokit/plugin-retry": "^5.0.5",
|
||||
"@octokit/plugin-retry": "^4.1.1",
|
||||
"lodash.deburr": "^4.1.0",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
@@ -61,7 +61,7 @@
|
||||
"jest": "^29.6.2",
|
||||
"jest-circus": "^29.5.0",
|
||||
"jest-silent-reporter": "^0.5.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"prettier": "^2.8.7",
|
||||
"standard-version": "^9.3.1",
|
||||
"terminal-link": "^2.1.1",
|
||||
|
||||
@@ -608,7 +608,7 @@ export class IssuesProcessor {
|
||||
async getLabelCreationDate(
|
||||
issue: Issue,
|
||||
label: string
|
||||
): Promise<string | undefined> {
|
||||
): Promise<{creationDate?: string; events: IIssueEvent[]}> {
|
||||
const issueLogger: IssueLogger = new IssueLogger(issue);
|
||||
|
||||
issueLogger.info(`Checking for label on this $$type`);
|
||||
@@ -623,6 +623,7 @@ export class IssuesProcessor {
|
||||
});
|
||||
|
||||
const events: IIssueEvent[] = await this.client.paginate(options);
|
||||
|
||||
const reversedEvents = events.reverse();
|
||||
|
||||
const staleLabeledEvent = reversedEvents.find(
|
||||
@@ -633,10 +634,51 @@ export class IssuesProcessor {
|
||||
|
||||
if (!staleLabeledEvent) {
|
||||
// Must be old rather than labeled
|
||||
return undefined;
|
||||
return {creationDate: undefined, events};
|
||||
}
|
||||
|
||||
return staleLabeledEvent.created_at;
|
||||
return {creationDate: staleLabeledEvent.created_at, events};
|
||||
}
|
||||
|
||||
protected async hasOnlyStaleLabelingEventsSince(
|
||||
issue: Issue,
|
||||
sinceDate: string,
|
||||
staleLabel: string,
|
||||
events: IIssueEvent[]
|
||||
): Promise<boolean> {
|
||||
const issueLogger: IssueLogger = new IssueLogger(issue);
|
||||
|
||||
issueLogger.info(
|
||||
`Checking if only stale label added events on $$type since: ${LoggerService.cyan(
|
||||
sinceDate
|
||||
)}`
|
||||
);
|
||||
|
||||
if (!sinceDate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const sinceTimestamp = new Date(sinceDate).getTime();
|
||||
if (Number.isNaN(sinceTimestamp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const relevantEvents = events.filter(event => {
|
||||
const eventTimestamp = new Date(event.created_at).getTime();
|
||||
return !Number.isNaN(eventTimestamp) && eventTimestamp >= sinceTimestamp;
|
||||
});
|
||||
|
||||
if (relevantEvents.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return relevantEvents.every(event => {
|
||||
if (event.event !== 'labeled') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cleanLabel(event.label.name) === cleanLabel(staleLabel);
|
||||
});
|
||||
}
|
||||
|
||||
async getPullRequest(issue: Issue): Promise<IPullRequest | undefined | void> {
|
||||
@@ -691,8 +733,11 @@ export class IssuesProcessor {
|
||||
closeLabel?: string
|
||||
) {
|
||||
const issueLogger: IssueLogger = new IssueLogger(issue);
|
||||
const markedStaleOn: string =
|
||||
(await this.getLabelCreationDate(issue, staleLabel)) || issue.updated_at;
|
||||
const {creationDate, events} = await this.getLabelCreationDate(
|
||||
issue,
|
||||
staleLabel
|
||||
);
|
||||
const markedStaleOn: string = creationDate || issue.updated_at;
|
||||
issueLogger.info(
|
||||
`$$type marked stale on: ${LoggerService.cyan(markedStaleOn)}`
|
||||
);
|
||||
@@ -744,12 +789,33 @@ export class IssuesProcessor {
|
||||
|
||||
// The issue.updated_at and markedStaleOn are not always exactly in sync (they can be off by a second or 2)
|
||||
// isDateMoreRecentThan makes sure they are not the same date within a certain tolerance (15 seconds in this case)
|
||||
const issueHasUpdateSinceStale = isDateMoreRecentThan(
|
||||
let issueHasUpdateSinceStale = isDateMoreRecentThan(
|
||||
new Date(issue.updated_at),
|
||||
new Date(markedStaleOn),
|
||||
15
|
||||
);
|
||||
|
||||
// Check if the only update was the stale label being added
|
||||
if (
|
||||
issueHasUpdateSinceStale &&
|
||||
shouldRemoveStaleWhenUpdated &&
|
||||
!issue.markedStaleThisRun
|
||||
) {
|
||||
const onlyStaleLabelAdded = await this.hasOnlyStaleLabelingEventsSince(
|
||||
issue,
|
||||
markedStaleOn,
|
||||
staleLabel,
|
||||
events
|
||||
);
|
||||
|
||||
if (onlyStaleLabelAdded) {
|
||||
issueHasUpdateSinceStale = false;
|
||||
issueLogger.info(
|
||||
`Ignoring $$type update since only the stale label was added`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
issueLogger.info(
|
||||
`$$type has been updated since it was marked stale: ${LoggerService.cyan(
|
||||
issueHasUpdateSinceStale
|
||||
|
||||
Reference in New Issue
Block a user