From 9044aa6e13d906fafd43289a7c610f574e3e123d Mon Sep 17 00:00:00 2001 From: Furior Date: Sat, 20 Jul 2024 19:16:06 +0700 Subject: [PATCH 01/13] I did not test this --- .../workflows/detect_translate_conflicts.yml | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 97feee0884552..450655131916a 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -19,6 +19,7 @@ jobs: run: | git config --local user.email "action@github.com" git config --local user.name "SS220Manager" + git config --local merge.conflictStyle zdiff3 - name: Try merging continue-on-error: true run: | @@ -28,10 +29,12 @@ jobs: { echo "MERGE_CONFLICTS<" + echo "$file" echo -e "\n\`\`\`diff" git diff --diff-filter=U "$file" | sed -n '/<<<<<<>>>>>>/p' echo -e "\n\`\`\`" + echo "" done echo EOF } >> $GITHUB_ENV @@ -39,15 +42,31 @@ jobs: uses: actions/github-script@v7 with: script: | - const { MERGE_CONFLICTS } = process.env + const { MERGE_CONFLICTS } = process.env; + const { issue_number, owner, repo } = context.repo; + const conflict_message = `This PR causes following conflicts on translate branch:\n${MERGE_CONFLICTS}`; - if(!MERGE_CONFLICTS) { - return - } + const comments = await github.rest.issues.listComments({ + owner, + repo, + issue_number, + }); + + const action_comment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); + if (action_comment) { + const commentId = action_comment.id; - await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `This pr causes following conflicts on translate branch:\n ${MERGE_CONFLICTS} ` - }) + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: commentId, + body: conflict_message, + }); + } else { + await github.rest.issues.createComment({ + owner, + repo, + issue_number, + body: conflict_message, + }); + } From 3db3412d71d41614cc1c9097183207af4dfa0aeb Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 21:18:56 +0700 Subject: [PATCH 02/13] testing stuff --- .github/workflows/detect_translate_conflicts.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 450655131916a..ba7d8985dbd81 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -44,7 +44,8 @@ jobs: script: | const { MERGE_CONFLICTS } = process.env; const { issue_number, owner, repo } = context.repo; - const conflict_message = `This PR causes following conflicts on translate branch:\n${MERGE_CONFLICTS}`; + const conflict_message_header = "This PR causes following conflicts on translate branch:\n" + const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; const comments = await github.rest.issues.listComments({ owner, @@ -52,21 +53,21 @@ jobs: issue_number, }); - const action_comment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); + const action_comment = comments.data.find(comment => comment.body.includes(conflict_message_header)); // && comment.user.login === "github-actions[bot]"); if (action_comment) { - const commentId = action_comment.id; + const comment_id = action_comment.id; await github.rest.issues.updateComment({ owner, repo, - comment_id: commentId, - body: conflict_message, + comment_id: comment_id, + body: issue_body, }); } else { await github.rest.issues.createComment({ owner, repo, issue_number, - body: conflict_message, + body: issue_body, }); } From a9588c7fdb57e0cf38f6025f55653e40652ad02c Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 21:20:12 +0700 Subject: [PATCH 03/13] latest action ver --- .github/workflows/detect_translate_conflicts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index ba7d8985dbd81..db0b980f9f696 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -39,7 +39,7 @@ jobs: echo EOF } >> $GITHUB_ENV - name: Run script - uses: actions/github-script@v7 + uses: actions/github-script@v7.0.1 with: script: | const { MERGE_CONFLICTS } = process.env; From 531f4b40cbe135a43248ba9cf240763dcfe198ac Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 21:21:16 +0700 Subject: [PATCH 04/13] nvm, 7 uses latest 7.x.x version --- .github/workflows/detect_translate_conflicts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index db0b980f9f696..ba7d8985dbd81 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -39,7 +39,7 @@ jobs: echo EOF } >> $GITHUB_ENV - name: Run script - uses: actions/github-script@v7.0.1 + uses: actions/github-script@v7 with: script: | const { MERGE_CONFLICTS } = process.env; From 79abbe5c2d88a26d8d21fec9f15dc9142c0a4ce8 Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 21:37:56 +0700 Subject: [PATCH 05/13] what if --- .github/workflows/detect_translate_conflicts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index ba7d8985dbd81..3d4d32dc55441 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -39,7 +39,7 @@ jobs: echo EOF } >> $GITHUB_ENV - name: Run script - uses: actions/github-script@v7 + uses: actions/github-script@v6 with: script: | const { MERGE_CONFLICTS } = process.env; @@ -53,7 +53,7 @@ jobs: issue_number, }); - const action_comment = comments.data.find(comment => comment.body.includes(conflict_message_header)); // && comment.user.login === "github-actions[bot]"); + const action_comment = comments.data.find(comment => comment.body.includes(conflict_message_header) && comment.user.login === "github-actions[bot]"); if (action_comment) { const comment_id = action_comment.id; From 003a8ec4672c07d7f180f82fdeb3b946837eda8f Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 21:57:36 +0700 Subject: [PATCH 06/13] I hate js --- .../workflows/detect_translate_conflicts.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 3d4d32dc55441..0078768eddb4f 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -39,18 +39,17 @@ jobs: echo EOF } >> $GITHUB_ENV - name: Run script - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: script: | const { MERGE_CONFLICTS } = process.env; - const { issue_number, owner, repo } = context.repo; const conflict_message_header = "This PR causes following conflicts on translate branch:\n" const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; const comments = await github.rest.issues.listComments({ - owner, - repo, - issue_number, + context.repo.owner, + context.repo.repo, + context.issue.number, }); const action_comment = comments.data.find(comment => comment.body.includes(conflict_message_header) && comment.user.login === "github-actions[bot]"); @@ -58,15 +57,15 @@ jobs: const comment_id = action_comment.id; await github.rest.issues.updateComment({ - owner, - repo, + context.repo.owner, + context.repo.repo, comment_id: comment_id, body: issue_body, }); } else { await github.rest.issues.createComment({ - owner, - repo, + context.repo.owner, + context.repo.repo, issue_number, body: issue_body, }); From ef3c188242e9a7d07c3eca2f2f3c1fc66db72e2c Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 22:03:26 +0700 Subject: [PATCH 07/13] ; --- .github/workflows/detect_translate_conflicts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 0078768eddb4f..e9f2674c6eb95 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -43,7 +43,7 @@ jobs: with: script: | const { MERGE_CONFLICTS } = process.env; - const conflict_message_header = "This PR causes following conflicts on translate branch:\n" + const conflict_message_header = "This PR causes following conflicts on translate branch:\n"; const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; const comments = await github.rest.issues.listComments({ From 4071e72511ec14002b5d856f637e5fb01f846584 Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 22:12:18 +0700 Subject: [PATCH 08/13] I hate js --- .../workflows/detect_translate_conflicts.yml | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index e9f2674c6eb95..5471bf3ebf035 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -42,31 +42,31 @@ jobs: uses: actions/github-script@v7 with: script: | - const { MERGE_CONFLICTS } = process.env; - const conflict_message_header = "This PR causes following conflicts on translate branch:\n"; - const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; + const { MERGE_CONFLICTS } = process.env; + const conflict_message_header = "This PR causes following conflicts on translate branch:\n"; + const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; - const comments = await github.rest.issues.listComments({ - context.repo.owner, - context.repo.repo, - context.issue.number, - }); + const comments = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); - const action_comment = comments.data.find(comment => comment.body.includes(conflict_message_header) && comment.user.login === "github-actions[bot]"); - if (action_comment) { - const comment_id = action_comment.id; + const action_comment = comments.data.find(comment => comment.body.startsWith(conflict_message_header) && comment.user.login === "github-actions[bot]"); + if (action_comment) { + const comment_id = action_comment.id; - await github.rest.issues.updateComment({ - context.repo.owner, - context.repo.repo, - comment_id: comment_id, - body: issue_body, - }); - } else { - await github.rest.issues.createComment({ - context.repo.owner, - context.repo.repo, - issue_number, - body: issue_body, - }); - } + await github.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment_id, + body: issue_body, + }); + } else { + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: issue_body, + }); + } From 1094362f8ab6fd79a248deafadb954d10a9e0bdb Mon Sep 17 00:00:00 2001 From: Furior Date: Thu, 15 Aug 2024 23:27:30 +0700 Subject: [PATCH 09/13] rest --- .github/workflows/detect_translate_conflicts.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 5471bf3ebf035..94d940a738df6 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -56,14 +56,14 @@ jobs: if (action_comment) { const comment_id = action_comment.id; - await github.issues.updateComment({ + await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: comment_id, body: issue_body, }); } else { - await github.issues.createComment({ + await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, From 34495dedf04f03359a2b7d8f53b0ebafd102eca1 Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 16 Aug 2024 00:54:01 +0700 Subject: [PATCH 10/13] Dont comment on no conflicts --- .github/workflows/detect_translate_conflicts.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 94d940a738df6..146ef060ec772 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -43,6 +43,11 @@ jobs: with: script: | const { MERGE_CONFLICTS } = process.env; + + if (!MERGE_CONFLICTS) { + return; + } + const conflict_message_header = "This PR causes following conflicts on translate branch:\n"; const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; From a3a166a03cc48eeca32fed51d20f4ff25be8318f Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 16 Aug 2024 00:55:19 +0700 Subject: [PATCH 11/13] conflict --- code/game/objects/items/mail.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/mail.dm b/code/game/objects/items/mail.dm index 2aec478162445..1adf0bfee1c53 100644 --- a/code/game/objects/items/mail.dm +++ b/code/game/objects/items/mail.dm @@ -1,6 +1,6 @@ /// Mail is tamper-evident and unresealable, postmarked by CentCom for an individual recepient. /obj/item/mail - name = "mail" + name = "конфликтное письмо" gender = NEUTER desc = "An officially postmarked, tamper-evident parcel regulated by CentCom and made of high-quality materials." icon = 'icons/obj/service/bureaucracy.dmi' From 1cfb46b969f00a6e53e727003e2a8910952d866b Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 16 Aug 2024 00:59:09 +0700 Subject: [PATCH 12/13] Revert "conflict" This reverts commit a3a166a03cc48eeca32fed51d20f4ff25be8318f. --- code/game/objects/items/mail.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/mail.dm b/code/game/objects/items/mail.dm index 1adf0bfee1c53..2aec478162445 100644 --- a/code/game/objects/items/mail.dm +++ b/code/game/objects/items/mail.dm @@ -1,6 +1,6 @@ /// Mail is tamper-evident and unresealable, postmarked by CentCom for an individual recepient. /obj/item/mail - name = "конфликтное письмо" + name = "mail" gender = NEUTER desc = "An officially postmarked, tamper-evident parcel regulated by CentCom and made of high-quality materials." icon = 'icons/obj/service/bureaucracy.dmi' From 1ad19c09bdaca167f7c4d13672b6de29e4969d89 Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 16 Aug 2024 01:05:05 +0700 Subject: [PATCH 13/13] delete comment if no conflicts anymore --- .github/workflows/detect_translate_conflicts.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/detect_translate_conflicts.yml b/.github/workflows/detect_translate_conflicts.yml index 146ef060ec772..e8f126ff9beef 100644 --- a/.github/workflows/detect_translate_conflicts.yml +++ b/.github/workflows/detect_translate_conflicts.yml @@ -44,10 +44,6 @@ jobs: script: | const { MERGE_CONFLICTS } = process.env; - if (!MERGE_CONFLICTS) { - return; - } - const conflict_message_header = "This PR causes following conflicts on translate branch:\n"; const issue_body = `${conflict_message_header}${MERGE_CONFLICTS}`; @@ -58,16 +54,26 @@ jobs: }); const action_comment = comments.data.find(comment => comment.body.startsWith(conflict_message_header) && comment.user.login === "github-actions[bot]"); + if (action_comment) { const comment_id = action_comment.id; + if (!MERGE_CONFLICTS) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: comment_id, + }); + return; + } + await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: comment_id, body: issue_body, }); - } else { + } else if (MERGE_CONFLICTS) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo,