fix bug when only title is not english

This commit is contained in:
tomsun28
2021-08-17 23:34:30 +08:00
parent e94f6e8fa0
commit 026728a9ea
3 changed files with 35 additions and 5 deletions
Generated Vendored
+18 -2
View File
@@ -4636,7 +4636,6 @@ function run() {
if (originComment === null || originComment === 'null') {
needCommitComment = false;
}
translateOrigin = originComment;
needCommitTitle = false;
}
else {
@@ -4652,7 +4651,6 @@ function run() {
if (originTitle === null || originTitle === 'null') {
needCommitTitle = false;
}
translateOrigin = originComment + '@@====' + originTitle;
}
// detect issue title comment body is english
if (originComment !== null && detectIsEnglish(originComment)) {
@@ -4667,6 +4665,15 @@ function run() {
core.info('Detect the issue do not need translated, return.');
return;
}
if (needCommitComment && needCommitTitle) {
translateOrigin = originComment + '@@====' + originTitle;
}
else if (needCommitComment) {
translateOrigin = originComment;
}
else {
translateOrigin = 'null@@====' + originTitle;
}
// ignore when bot comment issue himself
let botToken = core.getInput('BOT_GITHUB_TOKEN');
let botLoginName = core.getInput('BOT_LOGIN_NAME');
@@ -4709,10 +4716,19 @@ function run() {
core.info(`translate body is: ${translateTmp}`);
if (translateBody.length == 1) {
translateComment = translateBody[0].trim();
if (translateComment === originComment) {
needCommitComment = false;
}
}
else if (translateBody.length == 2) {
translateComment = translateBody[0].trim();
translateTitle = translateBody[1].trim();
if (translateComment === originComment) {
needCommitComment = false;
}
if (translateTitle === originTitle) {
needCommitTitle = false;
}
}
else {
core.setFailed(`the translateBody is ${translateTmp}`);
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+16 -2
View File
@@ -37,7 +37,6 @@ async function run(): Promise<void> {
if (originComment === null || originComment === 'null') {
needCommitComment = false
}
translateOrigin = originComment
needCommitTitle = false
} else {
const issuePayload = github.context
@@ -52,7 +51,6 @@ async function run(): Promise<void> {
if (originTitle === null || originTitle === 'null') {
needCommitTitle = false
}
translateOrigin = originComment + '@@====' + originTitle
}
// detect issue title comment body is english
@@ -68,6 +66,13 @@ async function run(): Promise<void> {
core.info('Detect the issue do not need translated, return.')
return
}
if (needCommitComment && needCommitTitle) {
translateOrigin = originComment + '@@====' + originTitle
} else if (needCommitComment) {
translateOrigin = originComment
} else {
translateOrigin = 'null@@====' + originTitle
}
// ignore when bot comment issue himself
let botToken = core.getInput('BOT_GITHUB_TOKEN')
@@ -126,9 +131,18 @@ async function run(): Promise<void> {
if (translateBody.length == 1) {
translateComment = translateBody[0].trim()
if (translateComment === originComment) {
needCommitComment = false
}
} else if (translateBody.length == 2) {
translateComment = translateBody[0].trim()
translateTitle = translateBody[1].trim()
if (translateComment === originComment) {
needCommitComment = false
}
if (translateTitle === originTitle) {
needCommitTitle = false
}
} else {
core.setFailed(`the translateBody is ${translateTmp}`)
}