diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fd76f8..fc1b441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog of the Pytest Coverage Comment +## [Pytest Coverage Comment 1.1.40](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.40) + +**Release Date:** 2022-12-03 + +#### Changes + +- Support for url for github enterprise repositories, thanks to [@jbcumming](https://github.com/jbcumming) for contribution + ## [Pytest Coverage Comment 1.1.39](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.39) **Release Date:** 2022-11-26 diff --git a/dist/index.js b/dist/index.js index 99c24db..0c43122 100644 --- a/dist/index.js +++ b/dist/index.js @@ -17168,7 +17168,7 @@ const toHtml = (data, options, dataFromXml = null) => { const total = dataFromXml ? dataFromXml.total : getTotal(data); const color = getCoverageColor(total.cover); const onlyChnaged = reportOnlyChangedFiles ? '• ' : ''; - const readmeHref = `https://github.com/${options.repository}/blob/${options.commit}/README.md`; + const readmeHref = `${options.repoUrl}/blob/${options.commit}/README.md`; const badge = `${badgeTitle}`; const badgeWithLink = removeLinkFromBadge ? badge @@ -17266,7 +17266,7 @@ const toTotalRow = (item, options) => { // make fileName cell - td const toFileNameTd = (item, indent = false, options) => { const relative = item.name.replace(options.prefix, ''); - const href = `https://github.com/${options.repository}/blob/${options.commit}/${options.pathPrefix}${relative}`; + const href = `${options.repoUrl}/blob/${options.commit}/${options.pathPrefix}${relative}`; const parts = relative.split('/'); const last = parts[parts.length - 1]; const space = indent ? '   ' : ''; @@ -17295,7 +17295,7 @@ const toMissingTd = (item, options) => { const [start, end = start] = range.split('-'); const fragment = start === end ? `L${start}` : `L${start}-L${end}`; const relative = item.name; - const href = `https://github.com/${options.repository}/blob/${options.commit}/${options.pathPrefix}${relative}#${fragment}`; + const href = `${options.repoUrl}/blob/${options.commit}/${options.pathPrefix}${relative}#${fragment}`; const text = start === end ? start : `${start}–${end}`; return `${text}`; @@ -17866,6 +17866,8 @@ const main = async () => { xmlTitle, multipleFiles, }; + options.repoUrl = + payload.repository?.html_url || `https://github.com/${options.repository}`; if (eventName === 'pull_request') { options.commit = payload.pull_request.head.sha; diff --git a/package-lock.json b/package-lock.json index 953632f..6ba3471 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pytest-coverage-comment", - "version": "1.1.39", + "version": "1.1.40", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pytest-coverage-comment", - "version": "1.1.39", + "version": "1.1.40", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", @@ -15,7 +15,7 @@ }, "devDependencies": { "@vercel/ncc": "^0.34.0", - "eslint": "^8.28.0", + "eslint": "^8.29.0", "prettier": "^2.8.0" } }, @@ -480,9 +480,9 @@ } }, "node_modules/eslint": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.28.0.tgz", - "integrity": "sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==", + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", + "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.3.3", @@ -1764,9 +1764,9 @@ } }, "eslint": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.28.0.tgz", - "integrity": "sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==", + "version": "8.29.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", + "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", "dev": true, "requires": { "@eslint/eslintrc": "^1.3.3", diff --git a/package.json b/package.json index 5445182..2a1149c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pytest-coverage-comment", - "version": "1.1.39", + "version": "1.1.40", "description": "Comments a pull request with the pytest code coverage badge, full report and tests summary", "author": "Misha Kav", "license": "MIT", @@ -33,7 +33,7 @@ }, "devDependencies": { "@vercel/ncc": "^0.34.0", - "eslint": "^8.28.0", + "eslint": "^8.29.0", "prettier": "^2.8.0" }, "prettier": { diff --git a/src/index.js b/src/index.js index 0bb4d3e..7534ee3 100644 --- a/src/index.js +++ b/src/index.js @@ -77,6 +77,8 @@ const main = async () => { xmlTitle, multipleFiles, }; + options.repoUrl = + payload.repository?.html_url || `https://github.com/${options.repository}`; if (eventName === 'pull_request') { options.commit = payload.pull_request.head.sha; diff --git a/src/parse.js b/src/parse.js index c196615..b88fb9b 100644 --- a/src/parse.js +++ b/src/parse.js @@ -194,7 +194,7 @@ const toHtml = (data, options, dataFromXml = null) => { const total = dataFromXml ? dataFromXml.total : getTotal(data); const color = getCoverageColor(total.cover); const onlyChnaged = reportOnlyChangedFiles ? '• ' : ''; - const readmeHref = `https://github.com/${options.repository}/blob/${options.commit}/README.md`; + const readmeHref = `${options.repoUrl}/blob/${options.commit}/README.md`; const badge = `${badgeTitle}`; const badgeWithLink = removeLinkFromBadge ? badge @@ -292,7 +292,7 @@ const toTotalRow = (item, options) => { // make fileName cell - td const toFileNameTd = (item, indent = false, options) => { const relative = item.name.replace(options.prefix, ''); - const href = `https://github.com/${options.repository}/blob/${options.commit}/${options.pathPrefix}${relative}`; + const href = `${options.repoUrl}/blob/${options.commit}/${options.pathPrefix}${relative}`; const parts = relative.split('/'); const last = parts[parts.length - 1]; const space = indent ? '   ' : ''; @@ -321,7 +321,7 @@ const toMissingTd = (item, options) => { const [start, end = start] = range.split('-'); const fragment = start === end ? `L${start}` : `L${start}-L${end}`; const relative = item.name; - const href = `https://github.com/${options.repository}/blob/${options.commit}/${options.pathPrefix}${relative}#${fragment}`; + const href = `${options.repoUrl}/blob/${options.commit}/${options.pathPrefix}${relative}#${fragment}`; const text = start === end ? start : `${start}–${end}`; return `${text}`;