From 3cd24426bf20b992e361aeccb441567fbcd127e6 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Tue, 29 Dec 2020 13:51:21 +0800 Subject: [PATCH] fix: check inactive (#22) * fix: check inactive * add --- README.en-US.md | 38 ++++++++++++++++++++++++++++++-------- README.md | 38 ++++++++++++++++++++++++++++++-------- dist/index.js | 40 +++++++++++++++++++++++----------------- docs/advanced.en-US.md | 9 ++++++--- docs/advanced.md | 9 ++++++--- docs/changelog.en-US.md | 2 +- docs/changelog.md | 2 +- docs/log.md | 6 ++++++ package.json | 2 +- src/advanced.js | 40 +++++++++++++++++++++++----------------- 10 files changed, 127 insertions(+), 59 deletions(-) diff --git a/README.en-US.md b/README.en-US.md index b391683..872e206 100644 --- a/README.en-US.md +++ b/README.en-US.md @@ -558,6 +558,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | +| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1 | | labels | Labels filtering | string | ✖ | v1.1 | | issue-state | State filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | @@ -565,7 +566,7 @@ jobs: | issue-mentioned | Mentioned filtering | string | ✖ | v1 | | body-includes | Body filtering | string | ✖ | v1 | | title-includes | Title filtering | string | ✖ | v1 | -| inactive-day | Inactive days filtering | number | ✖ | v1.2 | +| inactive-day | Inactive days filtering | number | ✖ | v1.4 | | inactive-label | The label name adding | string | ✖ | v1 | - `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all @@ -650,13 +651,14 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | +| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1 | | labels | Labels filtering | string | ✖ | v1.1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | | issue-creator | Creator filtering | string | ✖ | v1 | | issue-mentioned | Mentioned filtering | string | ✖ | v1 | | body-includes | Body filtering | string | ✖ | v1 | | title-includes | Title filtering | string | ✖ | v1 | -| inactive-day | Inactive days filtering | number | ✖ | v1.2 | +| inactive-day | Inactive days filtering | number | ✖ | v1.4 | - `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all - `issue-assignee`: Multiplayer is not supported. If you do not enter or enter *, all will be searched. Entering `none` will query issues for which the specified person is not added @@ -731,6 +733,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | +| contents | Add [reaction](#reactions-types) for this comment | string | ✖ | v1 | | labels | Labels filtering | string | ✖ | v1.1 | | issue-state | State filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | @@ -738,7 +741,7 @@ jobs: | issue-mentioned | Mentioned filtering | string | ✖ | v1 | | body-includes | Body filtering | string | ✖ | v1 | | title-includes | Title filtering | string | ✖ | v1 | -| inactive-day | Inactive days filtering | number | ✖ | v1.2 | +| inactive-day | Inactive days filtering | number | ✖ | v1.4 | - `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all - `issue-state`: The default is `all`. Optional value `open` `closed`, when these 2 items are not, both are `all` @@ -888,6 +891,25 @@ Click the `···` icon in the upper right corner of a comment, select `Copy lin ⏫ [Back to list](#List) +## ✨ Version + +- Version rules + - Use two-level semantic version, such as v1, v1.1, v2, v2.1 + - v1 represents the initial version + - The fixes and additions to the v1 version will be released to the v1.1 version + - When the released v1.x runs stable for a certain period of time, release the advanced v2 version + - The parameters in the API must use the largest version and above + +- Version selection + - It is recommended to use the latest releases version. It can be seen in [releases](https://github.com/actions-cool/issues-helper/releases) + - You can also refer to the update log below to select the version + - It also supports the direct use of branch versions. Such as: + +```yml +- name: Issues Helper + uses: actions-cool/issues-helper@main +``` + ## Actions Template - You can directly use this [GitHub Actions workflow template](https://github.com/actions-cool/.github) repositorie template @@ -929,19 +951,19 @@ At the same time, if you have any questions during use, you can also ask and inq - + ant-design - + ant-design-vue - + dumi - + umi - + vue-request diff --git a/README.md b/README.md index 622771b..8f10b71 100644 --- a/README.md +++ b/README.md @@ -556,6 +556,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | +| contents | 为该评论增加 [reaction](#reactions-types) | string | ✖ | v1 | | labels | 标签筛选 | string | ✖ | v1.1 | | issue-state | 状态筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | @@ -563,7 +564,7 @@ jobs: | issue-mentioned | 提及人筛选 | string | ✖ | v1 | | body-includes | 包含内容筛选 | string | ✖ | v1 | | title-includes | 包含标题筛选 | string | ✖ | v1 | -| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 | +| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 | | inactive-label | 新增标签名称 | string | ✖ | v1 | - `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有 @@ -644,13 +645,14 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | +| contents | 为该评论增加 [reaction](#reactions-types) | string | ✖ | v1 | | labels | 标签筛选 | string | ✖ | v1.1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | | issue-creator | 创建人筛选 | string | ✖ | v1 | | issue-mentioned | 提及人筛选 | string | ✖ | v1 | | body-includes | 包含内容筛选 | string | ✖ | v1 | | title-includes | 包含标题筛选 | string | ✖ | v1 | -| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 | +| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 | - `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有 - `issue-assignee`:不支持多人。不填或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues @@ -725,6 +727,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | +| contents | 为该评论增加 [reaction](#reactions-types) | string | ✖ | v1 | | labels | 标签筛选 | string | ✖ | v1.1 | | issue-state | 状态筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | @@ -732,7 +735,7 @@ jobs: | issue-mentioned | 提及人筛选 | string | ✖ | v1 | | body-includes | 包含内容筛选 | string | ✖ | v1 | | title-includes | 包含标题筛选 | string | ✖ | v1 | -| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 | +| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 | - `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有 - `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all` @@ -883,6 +886,25 @@ x2 + y2 ⏫ [返回列表](#列-表) +## ✨ 版本 + +- 版本规则 + - 采用两级语义化版本,如v1、v1.1、v2、v2.1 + - v1 表示初始版本 + - 对 v1 版本的修复和新增会发布到 v1.1 版本 + - 当发布的 v1.x 运行一定时间稳定后,发布进阶 v2 版本 + - API 中参数需使用其中最大及以上版本 + +- 版本选择 + - 建议采用最新 releases 版本。可在 [releases](https://github.com/actions-cool/issues-helper/releases) 看到 + - 同时也可参照下面的更新日志来选择版本 + - 也支持直接使用分支版本。如: + +```yml +- name: Issues Helper + uses: actions-cool/issues-helper@main +``` + ## Actions 模板 - 可直接使用这个 [GitHub Actions workflow template](https://github.com/actions-cool/.github) 仓库的模板 @@ -924,19 +946,19 @@ x2 + y2 - + ant-design - + ant-design-vue - + dumi - + umi - + vue-request diff --git a/dist/index.js b/dist/index.js index e5e52e6..5609605 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6213,26 +6213,32 @@ async function doQueryIssues (owner, repo, labels, state, creator) { const res = await octokit.issues.listForRepo(params); let issues = []; - res.data.forEach(iss => { - const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true; - const b = titleIncludes ? iss.title.includes(titleIncludes) : true; - /** - * Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. - * For this reason, "Issues" endpoints may return both issues and pull requests in the response. - * You can identify pull requests by the pull_request key. - */ - if (a && b && iss.pull_request === undefined) { - if (inactiveDay && typeof(inactiveDay) === 'number') { - let lastTime = dayjs.utc().subtract(inactiveDay, 'day'); - let updateTime = dayjs.utc(iss.updated_at); - if (updateTime.isSameOrBefore(lastTime)) { + let issueNumbers = []; + if (res.data.length) { + res.data.forEach(iss => { + const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true; + const b = titleIncludes ? iss.title.includes(titleIncludes) : true; + /** + * Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. + * For this reason, "Issues" endpoints may return both issues and pull requests in the response. + * You can identify pull requests by the pull_request key. + */ + if (a && b && iss.pull_request === undefined) { + if (inactiveDay) { + let lastTime = dayjs.utc().subtract(Number(inactiveDay), 'day'); + let updateTime = dayjs.utc(iss.updated_at); + if (updateTime.isSameOrBefore(lastTime)) { + issues.push(iss); + issueNumbers.push(iss.number); + } + } else { issues.push(iss); + issueNumbers.push(iss.number); } - } else { - issues.push(iss); } - } - }) + }) + core.info(`Actions: [query-issues]: [${JSON.stringify(issueNumbers)}]!`); + } return issues; }; diff --git a/docs/advanced.en-US.md b/docs/advanced.en-US.md index f13a7f7..15a7315 100644 --- a/docs/advanced.en-US.md +++ b/docs/advanced.en-US.md @@ -34,6 +34,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | +| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1 | | labels | Labels filtering | string | ✖ | v1.1 | | issue-state | State filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | @@ -41,7 +42,7 @@ jobs: | issue-mentioned | Mentioned filtering | string | ✖ | v1 | | body-includes | Body filtering | string | ✖ | v1 | | title-includes | Title filtering | string | ✖ | v1 | -| inactive-day | Inactive days filtering | number | ✖ | v1.2 | +| inactive-day | Inactive days filtering | number | ✖ | v1.4 | | inactive-label | The label name adding | string | ✖ | v1 | - `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all @@ -122,13 +123,14 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | +| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1 | | labels | Labels filtering | string | ✖ | v1.1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | | issue-creator | Creator filtering | string | ✖ | v1 | | issue-mentioned | Mentioned filtering | string | ✖ | v1 | | body-includes | Body filtering | string | ✖ | v1 | | title-includes | Title filtering | string | ✖ | v1 | -| inactive-day | Inactive days filtering | number | ✖ | v1.2 | +| inactive-day | Inactive days filtering | number | ✖ | v1.4 | - `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all - `issue-assignee`: Multiplayer is not supported. If you do not enter or enter *, all will be searched. Entering `none` will query issues for which the specified person is not added @@ -199,6 +201,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](/en-US/guide/ref#-token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | +| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ | v1 | | labels | Labels filtering | string | ✖ | v1.1 | | issue-state | State filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | @@ -206,7 +209,7 @@ jobs: | issue-mentioned | Mentioned filtering | string | ✖ | v1 | | body-includes | Body filtering | string | ✖ | v1 | | title-includes | Title filtering | string | ✖ | v1 | -| inactive-day | Inactive days filtering | number | ✖ | v1.2 | +| inactive-day | Inactive days filtering | number | ✖ | v1.4 | - `labels`: When there are multiple, the query will have multiple at the same time. If not entered, all - `issue-state`: The default is `all`. Optional value `open` `closed`, when these 2 items are not, both are `all` diff --git a/docs/advanced.md b/docs/advanced.md index 598eeab..3a41efa 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -34,6 +34,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | +| contents | 为该评论增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1 | | labels | 标签筛选 | string | ✖ | v1.1 | | issue-state | 状态筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | @@ -41,7 +42,7 @@ jobs: | issue-mentioned | 提及人筛选 | string | ✖ | v1 | | body-includes | 包含内容筛选 | string | ✖ | v1 | | title-includes | 包含标题筛选 | string | ✖ | v1 | -| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 | +| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 | | inactive-label | 新增标签名称 | string | ✖ | v1 | - `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有 @@ -118,13 +119,14 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | +| contents | 为该评论增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1 | | labels | 标签筛选 | string | ✖ | v1.1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | | issue-creator | 创建人筛选 | string | ✖ | v1 | | issue-mentioned | 提及人筛选 | string | ✖ | v1 | | body-includes | 包含内容筛选 | string | ✖ | v1 | | title-includes | 包含标题筛选 | string | ✖ | v1 | -| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 | +| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 | - `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有 - `issue-assignee`:不支持多人。不填或输入 * 时,查询所有。输入 `none` 会查询未添加指定人的 issues @@ -195,6 +197,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](/guide/ref#-token-说明) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | +| contents | 为该评论增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ | v1 | | labels | 标签筛选 | string | ✖ | v1.1 | | issue-state | 状态筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | @@ -202,7 +205,7 @@ jobs: | issue-mentioned | 提及人筛选 | string | ✖ | v1 | | body-includes | 包含内容筛选 | string | ✖ | v1 | | title-includes | 包含标题筛选 | string | ✖ | v1 | -| inactive-day | 非活跃天数筛选 | number | ✖ | v1.2 | +| inactive-day | 非活跃天数筛选 | number | ✖ | v1.4 | - `labels`:为多个时,会查询同时拥有多个。不填时,会查询所有 - `issue-state`:默认为 `all`。可选值 `open` `closed`,非这 2 项时,均为 `all` diff --git a/docs/changelog.en-US.md b/docs/changelog.en-US.md index ea78f8d..bb046b2 100644 --- a/docs/changelog.en-US.md +++ b/docs/changelog.en-US.md @@ -9,7 +9,7 @@ toc: menu - v1 represents the initial version - The fixes and additions to the v1 version will be released to the v1.1 version - When the released v1.x runs stable for a certain period of time, release the advanced v2 version - - It is recommended to use the largest version and above for the parameters in the API + - The parameters in the API must use the largest version and above - Version selection - It is recommended to use the latest releases version. It can be seen in [releases](https://github.com/actions-cool/issues-helper/releases) diff --git a/docs/changelog.md b/docs/changelog.md index ded8e76..2af26a4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -9,7 +9,7 @@ toc: menu - v1 表示初始版本 - 对 v1 版本的修复和新增会发布到 v1.1 版本 - 当发布的 v1.x 运行一定时间稳定后,发布进阶 v2 版本 - - API 中参数建议使用其中最大及以上版本 + - API 中参数需使用其中最大及以上版本 - 版本选择 - 建议采用最新 releases 版本。可在 [releases](https://github.com/actions-cool/issues-helper/releases) 看到 diff --git a/docs/log.md b/docs/log.md index cfd0b64..10a2ffb 100644 --- a/docs/log.md +++ b/docs/log.md @@ -1,3 +1,9 @@ +## v1.4 + +`2020.12.29` + +- fix: perfect `inactive-day` check. [#22](https://github.com/actions-cool/issues-helper/pull/22) + ## v1.3 `2020.12.28` diff --git a/package.json b/package.json index c7c8eec..146325d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "issue-helper", - "version": "1.3.0", + "version": "1.4.0", "private": true, "description": "Some operations on issue.", "main": "src/main.js", diff --git a/src/advanced.js b/src/advanced.js index 28ec2e2..a47624c 100644 --- a/src/advanced.js +++ b/src/advanced.js @@ -186,26 +186,32 @@ async function doQueryIssues (owner, repo, labels, state, creator) { const res = await octokit.issues.listForRepo(params); let issues = []; - res.data.forEach(iss => { - const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true; - const b = titleIncludes ? iss.title.includes(titleIncludes) : true; - /** - * Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. - * For this reason, "Issues" endpoints may return both issues and pull requests in the response. - * You can identify pull requests by the pull_request key. - */ - if (a && b && iss.pull_request === undefined) { - if (inactiveDay && typeof(inactiveDay) === 'number') { - let lastTime = dayjs.utc().subtract(inactiveDay, 'day'); - let updateTime = dayjs.utc(iss.updated_at); - if (updateTime.isSameOrBefore(lastTime)) { + let issueNumbers = []; + if (res.data.length) { + res.data.forEach(iss => { + const a = bodyIncludes ? iss.body.includes(bodyIncludes) : true; + const b = titleIncludes ? iss.title.includes(titleIncludes) : true; + /** + * Note: GitHub's REST API v3 considers every pull request an issue, but not every issue is a pull request. + * For this reason, "Issues" endpoints may return both issues and pull requests in the response. + * You can identify pull requests by the pull_request key. + */ + if (a && b && iss.pull_request === undefined) { + if (inactiveDay) { + let lastTime = dayjs.utc().subtract(Number(inactiveDay), 'day'); + let updateTime = dayjs.utc(iss.updated_at); + if (updateTime.isSameOrBefore(lastTime)) { + issues.push(iss); + issueNumbers.push(iss.number); + } + } else { issues.push(iss); + issueNumbers.push(iss.number); } - } else { - issues.push(iss); } - } - }) + }) + core.info(`Actions: [query-issues]: [${JSON.stringify(issueNumbers)}]!`); + } return issues; };