Skip to content

Commit

Permalink
fix bug when only title is not english
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsun28 committed Aug 17, 2021
1 parent e94f6e8 commit 026728a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
20 changes: 18 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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}`)
}
Expand Down

0 comments on commit 026728a

Please sign in to comment.