You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2021/12/09 14:01:13 UTC
[echarts-bot] branch check-title created (now 2125322)
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a change to branch check-title
in repository https://gitbox.apache.org/repos/asf/echarts-bot.git.
at 2125322 feat: check if the title is valid when an issue is opened.
This branch includes the following new commits:
new 2125322 feat: check if the title is valid when an issue is opened.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts-bot] 01/01: feat: check if the title is valid when an issue is opened.
Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch check-title
in repository https://gitbox.apache.org/repos/asf/echarts-bot.git
commit 2125322ea42c7f79a640f889d73d5cfaece7f32c
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Thu Dec 9 21:59:28 2021 +0800
feat: check if the title is valid when an issue is opened.
---
index.js | 24 ++++++++++++++++++++----
src/issue.js | 15 +++++++++++++--
src/label.js | 2 ++
src/text.js | 13 ++++++++++++-
4 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/index.js b/index.js
index e4f4c24..fb254ca 100644
--- a/index.js
+++ b/index.js
@@ -25,7 +25,8 @@ module.exports = (/** @type import('probot').Probot */ app) => {
// add and remove label
await Promise.all([addLabels, removeLabel]);
- const invalid = issue.addLabels.includes(labelText.INVALID);
+ const invalid = issue.addLabels.includes(labelText.INVALID)
+ || issue.addLabels.includes(labelText.MISSING_TITLE);
// translate finally if valid
return invalid || translateIssue(context, issue);
@@ -62,13 +63,22 @@ module.exports = (/** @type import('probot').Probot */ app) => {
switch (labelName) {
case labelText.INVALID:
- return Promise.all([commentIssue(context, text.NOT_USING_TEMPLATE), closeIssue(context)]);
+ return Promise.all([
+ commentIssue(context, text.NOT_USING_TEMPLATE),
+ closeIssue(context)
+ ]);
case labelText.HOWTO:
- return Promise.all([commentIssue(context, text.LABEL_HOWTO), closeIssue(context)]);
+ return Promise.all([
+ commentIssue(context, text.LABEL_HOWTO),
+ closeIssue(context)
+ ]);
case labelText.INACTIVE:
- return Promise.all([commentIssue(context, text.INACTIVE_ISSUE), closeIssue(context)]);
+ return Promise.all([
+ commentIssue(context, text.INACTIVE_ISSUE),
+ closeIssue(context)
+ ]);
case labelText.MISSING_DEMO:
return Promise.all([
@@ -94,6 +104,12 @@ module.exports = (/** @type import('probot').Probot */ app) => {
closeIssue(context),
getRemoveLabel(context, labelText.WAITING_FOR_COMMUNITY)
]);
+
+ case labelText.MISSING_TITLE:
+ return Promise.all([
+ commentIssue(context, text.MISSING_TITLE),
+ closeIssue(context)
+ ]);
}
});
diff --git a/src/issue.js b/src/issue.js
index d370376..d80b75f 100644
--- a/src/issue.js
+++ b/src/issue.js
@@ -23,7 +23,12 @@ class Issue {
const isCore = isCommitter(this.issue.author_association, this.issue.user.login);
if (!isCore) {
- // avoid opening an issue with no template through `Reference in new issue`
+ // check if the title is valid
+ if (this.isMissingTitle()) {
+ this.addLabels.push(label.MISSING_TITLE);
+ return;
+ }
+ // prevent from opening an issue with no template via `Reference in new issue` button
if (!this.isUsingTemplate()) {
this.addLabels.push(label.INVALID);
return;
@@ -55,9 +60,15 @@ class Issue {
}
isUsingTemplate() {
- return this.body.indexOf('Steps To Reproduce') > -1
+ return this.body.indexOf('Steps to Reproduce') > -1
|| this.body.indexOf('What problem does this feature solve') > - 1;
}
+
+ isMissingTitle() {
+ console.log(this.title)
+ const title = this.title.trim()
+ return !title || !title.toLowerCase().replace('[bug]', '').replace('[feature]', '')
+ }
}
module.exports = Issue;
diff --git a/src/label.js b/src/label.js
index 3e524d2..7badd43 100644
--- a/src/label.js
+++ b/src/label.js
@@ -15,6 +15,7 @@ const RESOLVED = 'resolved';
const HOWTO = 'howto';
const INACTIVE = 'inactive';
const MISSING_DEMO = 'missing-demo';
+const MISSING_TITLE = 'missing-title';
const DUPLICATE = 'duplicate';
const PRIORITY_HIGH = 'priority: high';
@@ -41,6 +42,7 @@ module.exports = {
HOWTO,
INACTIVE,
MISSING_DEMO,
+ MISSING_TITLE,
DUPLICATE,
PRIORITY_HIGH,
PR_AWAITING_REVIEW,
diff --git a/src/text.js b/src/text.js
index eb9e729..4ae97a4 100644
--- a/src/text.js
+++ b/src/text.js
@@ -80,13 +80,24 @@ For (1), we have decided to use the GitHub issue lists exclusively for work that
For (2), we have found that issues that do not provide proper information upfront usually results in terribly inefficient back-and-forth communication just to extract the basic information needed for actual triaging. This is exactly why we have created this app: to ensure that every issue is created with the necessary information, and to save time on both sides.`;
-const ISSUE_COMMENT_TRANSLATE_TIP = 'AT_ISSUE_AUTHOR It seems you are not using English, I\'ve helped translate the content automatically. To make your issue understood by more people and get helped, we\'d like to suggest using English next time. 🤗';
+const ISSUE_COMMENT_TRANSLATE_TIP =
+ 'AT_ISSUE_AUTHOR It seems you are not using English, I\'ve helped translate the content automatically. To make your issue understood by more people and get helped, we\'d like to suggest using English next time. 🤗';
+
+const MISSING_TITLE =
+ `I'm sorry to close this issue for it lacks the necessary title. Please open a new issue **with a _descriptive_ and as _concise_ as possible title to describe your problems or requests**.
+
+Every good bug report or feature request starts with a title. Your issue title is a critical element as it's the first thing maintainers see.
+
+A good issue title makes it easier for maintainers to understand what the issue is, easily locate it, and know what steps they'll need to take to fix it.
+
+Moreover, it's better to include keywords, as this makes it easier to find the issue self and similar issues in searches.`;
module.exports = {
NOT_USING_TEMPLATE,
ISSUE_CREATED,
ISSUE_UPDATED,
MISSING_DEMO,
+ MISSING_TITLE,
INACTIVE_ISSUE,
PR_OPENED,
LABEL_HOWTO,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org