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 2022/06/19 14:10:48 UTC
[echarts-bot] branch master updated: fix: fix typos and `checkDoc` logic flaw.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-bot.git
The following commit(s) were added to refs/heads/master by this push:
new b229695 fix: fix typos and `checkDoc` logic flaw.
b229695 is described below
commit b229695775d9dda089e8dcb31f1d3ddc01d6a583
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Sun Jun 19 22:09:09 2022 +0800
fix: fix typos and `checkDoc` logic flaw.
---
index.js | 28 ++++++++++++++++++++--------
src/text.js | 8 ++++----
src/util.js | 21 +++++++++++----------
3 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/index.js b/index.js
index 43c4789..4786f53 100644
--- a/index.js
+++ b/index.js
@@ -420,30 +420,42 @@ function fixMarkdown(body) {
return body.replace(/\! \[/g, '![').replace(/\] \(/g, '](')
}
+/**
+ * @param {string} content
+ * @param {string} commentText
+ * @param {Array.<string>} addLabelList
+ * @param {Array.<string>} removeLabelList
+ */
function checkDoc(content, commentText, addLabelList, removeLabelList) {
if (isMissingDocInfo(content)) {
if (content.indexOf(text.PR_DOC_LATER) < 0) {
- commentText += '\n\n' + text.PR_DOC_LAGACY;
+ commentText += '\n\n' + text.PR_DOC_LEGACY;
}
else {
commentText += text.PR_MISSING_DOC_INFO;
}
}
else {
- if (content.indexOf('[x] ' + text.PR_DOC_RREADY) >= 0) {
+ if (content.indexOf('[x] ' + text.PR_DOC_READY) >= 0) {
addLabelList.push(labelText.PR_DOC_READY);
- removeLabelList.push(labelText.PR_DOC_UNCHANGED);
- removeLabelList.push(labelText.PR_DOC_LATER);
+ removeLabelList.push(
+ labelText.PR_DOC_UNCHANGED,
+ labelText.PR_AWAITING_DOC
+ );
}
else if (content.indexOf('[x] ' + text.PR_DOC_UNCHANGED) >= 0) {
addLabelList.push(labelText.PR_DOC_UNCHANGED);
- removeLabelList.push(labelText.PR_DOC_READY);
- removeLabelList.push(labelText.PR_DOC_LATER);
+ removeLabelList.push(
+ labelText.PR_DOC_READY,
+ labelText.PR_AWAITING_DOC
+ );
}
else if (content.indexOf('[x] ' + text.PR_DOC_LATER) >= 0) {
addLabelList.push(labelText.PR_AWAITING_DOC);
- removeLabelList.push(labelText.PR_DOC_UNCHANGED);
- removeLabelList.push(labelText.PR_DOC_READY);
+ removeLabelList.push(
+ labelText.PR_DOC_UNCHANGED,
+ labelText.PR_DOC_READY
+ );
commentText += text.PR_AWAITING_DOC;
}
}
diff --git a/src/text.js b/src/text.js
index 1ac160b..c664824 100644
--- a/src/text.js
+++ b/src/text.js
@@ -55,9 +55,9 @@ The pull request is marked to be \`PR: author is committer\` because you are a c
const PR_DOC_UNCHANGED = `This PR doesn't relate to document changes`;
const PR_DOC_LATER = `The document should be updated later`;
-const PR_DOC_RREADY = `The document changes have been made`;
+const PR_DOC_READY = `The document changes have been made`;
-const PR_DOC_LAGACY = `To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: \`PR: doc ready\`, \`PR: doc awaiting\`, \`PR: doc unchanged\`
+const PR_DOC_LEGACY = `To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: \`PR: doc ready\`, \`PR: awaiting doc\`, \`PR: doc unchanged\`
This message is shown because the PR description doesn't contain the document related template.`;
@@ -118,8 +118,8 @@ module.exports = {
PR_NOT_MERGED,
PR_DOC_UNCHANGED,
PR_DOC_LATER,
- PR_DOC_RREADY,
- PR_DOC_LAGACY,
+ PR_DOC_READY,
+ PR_DOC_LEGACY,
PR_MISSING_DOC_INFO,
PR_AWAITING_DOC,
PR_ZRENDER_CHANGED,
diff --git a/src/util.js b/src/util.js
index 81400eb..0f819e9 100644
--- a/src/util.js
+++ b/src/util.js
@@ -16,18 +16,19 @@ function replaceAll(str, search, replacement) {
return str.replace(new RegExp(search, 'g'), replacement);
}
+/**
+ * @param {string} body
+ */
function isMissingDocInfo(body) {
- const docOptions = [
- `[x] ${text.PR_DOC_UNCHANGED}`,
- `[x] ${text.PR_DOC_LATER}`,
- `[x] ${text.PR_DOC_RREADY}`
- ];
- for (let i = 0; i < docOptions.length; ++i) {
- if (body.indexOf(docOptions[i]) > -1) {
- return false;
- }
+ if (!body) {
+ return true;
}
- return true;
+ const docOptions = [
+ text.PR_DOC_UNCHANGED,
+ text.PR_DOC_LATER,
+ text.PR_DOC_READY
+ ].map(opt => `[x] ${opt}`);
+ return !docOptions.some(opt => body.includes(opt));
}
module.exports = {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org