Skip to content

Commit

Permalink
Merge pull request #9 from actions/main
Browse files Browse the repository at this point in the history
  • Loading branch information
C0ZEN authored Feb 13, 2021
2 parents abab4a6 + 07f3f88 commit 920683c
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 324 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $ npm test
| `ascending` | Order to get issues/pr. _Defaults to **false**_ | Optional |
| `skip-stale-issue-message` | Skip adding stale message on stale issue. _Defaults to **false**_ | Optional |
| `skip-stale-pr-message` | Skip adding stale message on stale pr. _Defaults to **false**_ | Optional |
| `delete-branch` | Delete the git branch after closing a stale pull request. _Defaults to **false**_ | Optional |
| `start-date` | The date used to skip the stale action on issue/pr created before it (ISO 8601 or RFC 2822). | Optional |

### Usage
Expand Down
249 changes: 125 additions & 124 deletions __tests__/main.test.ts

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,43 @@ module.exports =
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 4407:
/***/ 4783:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Issue = void 0;
const is_labeled_1 = __nccwpck_require__(6792);
const is_pull_request_1 = __nccwpck_require__(5400);
class Issue {
constructor(options, issue) {
this._options = options;
this.title = issue.title;
this.number = issue.number;
this.created_at = issue.created_at;
this.updated_at = issue.updated_at;
this.labels = issue.labels;
this.pull_request = issue.pull_request;
this.state = issue.state;
this.locked = issue.locked;
this.milestone = issue.milestone;
this.isPullRequest = is_pull_request_1.isPullRequest(this);
this.staleLabel = this._getStaleLabel();
this.isStale = is_labeled_1.isLabeled(this, this.staleLabel);
}
_getStaleLabel() {
return this.isPullRequest
? this._options.stalePrLabel
: this._options.staleIssueLabel;
}
}
exports.Issue = Issue;


/***/ }),

/***/ 3292:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";
Expand All @@ -17,12 +53,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.IssueProcessor = void 0;
exports.IssuesProcessor = void 0;
const github_1 = __nccwpck_require__(5438);
const issue_1 = __nccwpck_require__(4783);
const issue_logger_1 = __nccwpck_require__(2984);
const logger_1 = __nccwpck_require__(6212);
const milestones_1 = __nccwpck_require__(4601);
const get_humanized_date_1 = __nccwpck_require__(965);
const is_date_more_recent_than_1 = __nccwpck_require__(1473);
const is_valid_date_1 = __nccwpck_require__(891);
Expand All @@ -31,10 +63,14 @@ const is_labeled_1 = __nccwpck_require__(6792);
const is_pull_request_1 = __nccwpck_require__(5400);
const should_mark_when_stale_1 = __nccwpck_require__(2461);
const words_to_list_1 = __nccwpck_require__(1883);
const issue_1 = __nccwpck_require__(4783);
const issue_logger_1 = __nccwpck_require__(2984);
const logger_1 = __nccwpck_require__(6212);
const milestones_1 = __nccwpck_require__(4601);
/***
* Handle processing of issues for staleness/closure.
*/
class IssueProcessor {
class IssuesProcessor {
constructor(options, getActor, getIssues, listIssueComments, getLabelCreationDate) {
this._logger = new logger_1.Logger();
this._operationsLeft = 0;
Expand Down Expand Up @@ -157,7 +193,7 @@ class IssueProcessor {
continue; // don't process exempt milestones
}
// should this issue be marked stale?
const shouldBeStale = !IssueProcessor._updatedSince(issue.updated_at, daysBeforeStale);
const shouldBeStale = !IssuesProcessor._updatedSince(issue.updated_at, daysBeforeStale);
// determine if this issue needs to be marked stale first
if (!issue.isStale && shouldBeStale && shouldMarkAsStale) {
issueLogger.info(`Marking ${issueType} stale because it was last updated on ${issue.updated_at} and it does not have a stale label`);
Expand Down Expand Up @@ -199,7 +235,7 @@ class IssueProcessor {
else {
issueLogger.info(`Days before issue close: ${daysBeforeClose}`);
}
const issueHasUpdate = IssueProcessor._updatedSince(issue.updated_at, daysBeforeClose);
const issueHasUpdate = IssuesProcessor._updatedSince(issue.updated_at, daysBeforeClose);
issueLogger.info(`Issue #${issue.number} has been updated: ${issueHasUpdate}`);
// should we un-stale this issue?
if (this.options.removeStaleWhenUpdated && issueHasComments) {
Expand Down Expand Up @@ -503,43 +539,7 @@ class IssueProcessor {
});
}
}
exports.IssueProcessor = IssueProcessor;


/***/ }),

/***/ 4783:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Issue = void 0;
const is_labeled_1 = __nccwpck_require__(6792);
const is_pull_request_1 = __nccwpck_require__(5400);
class Issue {
constructor(options, issue) {
this._options = options;
this.title = issue.title;
this.number = issue.number;
this.created_at = issue.created_at;
this.updated_at = issue.updated_at;
this.labels = issue.labels;
this.pull_request = issue.pull_request;
this.state = issue.state;
this.locked = issue.locked;
this.milestone = issue.milestone;
this.isPullRequest = is_pull_request_1.isPullRequest(this);
this.staleLabel = this._getStaleLabel();
this.isStale = is_labeled_1.isLabeled(this, this.staleLabel);
}
_getStaleLabel() {
return this.isPullRequest
? this._options.stalePrLabel
: this._options.staleIssueLabel;
}
}
exports.Issue = Issue;
exports.IssuesProcessor = IssuesProcessor;


/***/ }),
Expand Down Expand Up @@ -924,12 +924,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const is_valid_date_1 = __nccwpck_require__(891);
const IssueProcessor_1 = __nccwpck_require__(4407);
const issues_processor_1 = __nccwpck_require__(3292);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const args = getAndValidateArgs();
const processor = new IssueProcessor_1.IssueProcessor(args);
const processor = new issues_processor_1.IssuesProcessor(args);
yield processor.processIssues();
}
catch (error) {
Expand Down
92 changes: 46 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@octokit/rest": "^18.0.12",
"@octokit/rest": "^18.1.0",
"lodash.deburr": "^4.1.0",
"semver": "^7.3.4"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/lodash.deburr": "^4.1.6",
"@types/node": "^14.14.21",
"@types/node": "^14.14.26",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"@vercel/ncc": "^0.27.0",
"eslint": "^7.18.0",
"eslint": "^7.19.0",
"eslint-plugin-github": "^4.0.1",
"eslint-plugin-jest": "^24.1.3",
"jest": "^26.6.3",
Expand Down
9 changes: 5 additions & 4 deletions src/classes/issue.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {IIssue} from '../interfaces/issue';
import {IIssuesProcessorOptions} from '../interfaces/issues-processor-options';
import {ILabel} from '../interfaces/label';
import {IMilestone} from '../interfaces/milestone';
import {IssueProcessorOptions, Label} from '../IssueProcessor';
import {Issue} from './issue';

describe('Issue', (): void => {
let issue: Issue;
let optionsInterface: IssueProcessorOptions;
let optionsInterface: IIssuesProcessorOptions;
let issueInterface: IIssue;

beforeEach((): void => {
Expand Down Expand Up @@ -91,7 +92,7 @@ describe('Issue', (): void => {
expect(issue.labels).toStrictEqual([
{
name: 'dummy-name'
} as Label
} as ILabel
]);
});

Expand Down Expand Up @@ -193,7 +194,7 @@ describe('Issue', (): void => {
issueInterface.labels = [
{
name: 'dummy-stale-issue-label'
} as Label
} as ILabel
];
issue = new Issue(optionsInterface, issueInterface);
});
Expand Down
Loading

0 comments on commit 920683c

Please sign in to comment.