tweak: do not add en label when issue contains over 5 Chinese characters.
diff --git a/src/issue.js b/src/issue.js
index efcbe60..6139a36 100644
--- a/src/issue.js
+++ b/src/issue.js
@@ -1,6 +1,9 @@
const text = require('./text');
const { isCommitter } = require('./coreCommitters');
+const REG_CHN_CHAR = /[\u4e00-\u9fa5]/g;
+const MAX_CHN_CHAR_COUNT = 5;
+
class Issue {
constructor(context) {
this.context = context;
@@ -57,7 +60,7 @@
this.addLabels.push(this.issueType);
const isInEnglish = this._contain('This issue is in English');
- if (isInEnglish) {
+ if (isInEnglish && !this._isMainlyUsingChinese()) {
this.addLabels.push('en');
}
}
@@ -65,6 +68,10 @@
_contain(txt) {
return this.body.indexOf(txt) > -1;
}
+
+ _isMainlyUsingChinese() {
+ return this.body.match(REG_CHN_CHAR).length > MAX_CHN_CHAR_COUNT;
+ }
}
module.exports = Issue;