From e2c4b20b8a59537ce08ed767c5bb63581e0651ae Mon Sep 17 00:00:00 2001 From: Misha Kav Date: Sat, 4 Feb 2023 18:10:45 +0200 Subject: [PATCH] fix sha when event is pull_request_target (#115) * fix sha when event is pull_request_target * 1.1.45 * changelog --- CHANGELOG.md | 8 ++++++++ dist/index.js | 3 ++- package-lock.json | 4 ++-- package.json | 2 +- src/index.js | 3 ++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58f035..2c9b56f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog of the Pytest Coverage Comment +## [Pytest Coverage Comment 1.1.45](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.45) + +**Release Date:** 2023-02-04 + +#### Changes + +- Fix commit sha in links when event is `pull_request_target` + ## [Pytest Coverage Comment 1.1.44](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.44) **Release Date:** 2023-01-31 diff --git a/dist/index.js b/dist/index.js index 6e0c9cc..87cb3be 100644 --- a/dist/index.js +++ b/dist/index.js @@ -17870,7 +17870,7 @@ const main = async () => { options.repoUrl = payload.repository?.html_url || `https://github.com/${options.repository}`; - if (eventName === 'pull_request') { + if (eventName === 'pull_request' || eventName === 'pull_request_target') { options.commit = payload.pull_request.head.sha; options.head = payload.pull_request.head.ref; options.base = payload.pull_request.base.ref; @@ -18047,6 +18047,7 @@ const getChangedFiles = async (options) => { switch (eventName) { case 'pull_request': + case 'pull_request_target': base = payload.pull_request.base.sha; head = payload.pull_request.head.sha; break; diff --git a/package-lock.json b/package-lock.json index 1a07e58..7f832d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pytest-coverage-comment", - "version": "1.1.44", + "version": "1.1.45", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pytest-coverage-comment", - "version": "1.1.44", + "version": "1.1.45", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index bfe8b6b..a7e5728 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pytest-coverage-comment", - "version": "1.1.44", + "version": "1.1.45", "description": "Comments a pull request with the pytest code coverage badge, full report and tests summary", "author": "Misha Kav", "license": "MIT", diff --git a/src/index.js b/src/index.js index 218866c..0165ada 100644 --- a/src/index.js +++ b/src/index.js @@ -80,7 +80,7 @@ const main = async () => { options.repoUrl = payload.repository?.html_url || `https://github.com/${options.repository}`; - if (eventName === 'pull_request') { + if (eventName === 'pull_request' || eventName === 'pull_request_target') { options.commit = payload.pull_request.head.sha; options.head = payload.pull_request.head.ref; options.base = payload.pull_request.base.ref; @@ -257,6 +257,7 @@ const getChangedFiles = async (options) => { switch (eventName) { case 'pull_request': + case 'pull_request_target': base = payload.pull_request.base.sha; head = payload.pull_request.head.sha; break;