Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GitHub enterprise urls #102

Merged
merged 4 commits into from Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions 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
Expand Down
8 changes: 5 additions & 3 deletions dist/index.js
Expand Up @@ -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 = `<img alt="${badgeTitle}" src="https://img.shields.io/badge/${badgeTitle}-${total.cover}25-${color}.svg" />`;
const badgeWithLink = removeLinkFromBadge
? badge
Expand Down Expand Up @@ -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 ? '&nbsp; &nbsp;' : '';
Expand Down Expand Up @@ -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}&ndash;${end}`;

return `<a href="${href}">${text}</a>`;
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions 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",
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@vercel/ncc": "^0.34.0",
"eslint": "^8.28.0",
"eslint": "^8.29.0",
"prettier": "^2.8.0"
},
"prettier": {
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/parse.js
Expand Up @@ -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 = `<img alt="${badgeTitle}" src="https://img.shields.io/badge/${badgeTitle}-${total.cover}25-${color}.svg" />`;
const badgeWithLink = removeLinkFromBadge
? badge
Expand Down Expand Up @@ -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 ? '&nbsp; &nbsp;' : '';
Expand Down Expand Up @@ -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}&ndash;${end}`;

return `<a href="${href}">${text}</a>`;
Expand Down