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

Trim on badge cover #142

Merged
merged 7 commits into from
Aug 2, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog of the Pytest Coverage Comment

## [Pytest Coverage Comment 1.1.48](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.48)

**Release Date:** 2023-08-02

#### Changes

- Fix wrong badge link when have an empty space in total coverage

## [Pytest Coverage Comment 1.1.47](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.47)

**Release Date:** 2023-03-18
Expand Down
28 changes: 16 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12110,14 +12110,14 @@ function wrappy (fn, cb) {
this.saxParser.onopentag = (function(_this) {
return function(node) {
var key, newValue, obj, processedKey, ref;
obj = {};
obj = Object.create(null);
obj[charkey] = "";
if (!_this.options.ignoreAttrs) {
ref = node.attributes;
for (key in ref) {
if (!hasProp.call(ref, key)) continue;
if (!(attrkey in obj) && !_this.options.mergeAttrs) {
obj[attrkey] = {};
obj[attrkey] = Object.create(null);
}
newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
Expand Down Expand Up @@ -12167,7 +12167,11 @@ function wrappy (fn, cb) {
}
}
if (isEmpty(obj)) {
obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
if (typeof _this.options.emptyTag === 'function') {
obj = _this.options.emptyTag();
} else {
obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
}
}
if (_this.options.validator != null) {
xpath = "/" + ((function() {
Expand All @@ -12191,7 +12195,7 @@ function wrappy (fn, cb) {
}
if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') {
if (!_this.options.preserveChildrenOrder) {
node = {};
node = Object.create(null);
if (_this.options.attrkey in obj) {
node[_this.options.attrkey] = obj[_this.options.attrkey];
delete obj[_this.options.attrkey];
Expand All @@ -12206,7 +12210,7 @@ function wrappy (fn, cb) {
obj = node;
} else if (s) {
s[_this.options.childkey] = s[_this.options.childkey] || [];
objClone = {};
objClone = Object.create(null);
for (key in obj) {
if (!hasProp.call(obj, key)) continue;
objClone[key] = obj[key];
Expand All @@ -12223,7 +12227,7 @@ function wrappy (fn, cb) {
} else {
if (_this.options.explicitRoot) {
old = obj;
obj = {};
obj = Object.create(null);
obj[nodeName] = old;
}
_this.resultObject = obj;
Expand Down Expand Up @@ -17086,16 +17090,16 @@ const parseOneLine = (line) => {
const isFullCoverage = lastItem === '100%';
const cover = isFullCoverage
? '100%'
: parsedLine[parsedLine.length - 2].trimStart();
: parsedLine[parsedLine.length - 2].trim();
const missing = isFullCoverage
? null
: parsedLine[parsedLine.length - 1] &&
parsedLine[parsedLine.length - 1].split(', ');

return {
name: parsedLine[0],
stmts: parsedLine[1].trimStart(),
miss: parsedLine[2].trimStart(),
stmts: parsedLine[1].trim(),
miss: parsedLine[2].trim(),
cover,
missing,
};
Expand All @@ -17115,9 +17119,9 @@ const parseTotalLine = (line) => {

return {
name: parsedLine[0],
stmts: parsedLine[1].trimStart(),
miss: parsedLine[2].trimStart(),
cover: parsedLine[parsedLine.length - 1].trimStart(),
stmts: parsedLine[1].trim(),
miss: parsedLine[2].trim(),
cover: parsedLine[parsedLine.length - 1].trim(),
};
};

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pytest-coverage-comment",
"version": "1.1.47",
"version": "1.1.48",
"description": "Comments a pull request with the pytest code coverage badge, full report and tests summary",
"author": "Misha Kav",
"license": "MIT",
Expand All @@ -24,6 +24,7 @@
"format-check": "prettier --check src/**/*.js",
"lint": "eslint src/**/*.js",
"build": "ncc build src/index.js --license licenses.txt",
"bump-version": "npm version patch",
"all": "npm run lint && npm run format && npm run build"
},
"dependencies": {
Expand Down
12 changes: 6 additions & 6 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ const parseOneLine = (line) => {
const isFullCoverage = lastItem === '100%';
const cover = isFullCoverage
? '100%'
: parsedLine[parsedLine.length - 2].trimStart();
: parsedLine[parsedLine.length - 2].trim();
const missing = isFullCoverage
? null
: parsedLine[parsedLine.length - 1] &&
parsedLine[parsedLine.length - 1].split(', ');

return {
name: parsedLine[0],
stmts: parsedLine[1].trimStart(),
miss: parsedLine[2].trimStart(),
stmts: parsedLine[1].trim(),
miss: parsedLine[2].trim(),
cover,
missing,
};
Expand All @@ -141,9 +141,9 @@ const parseTotalLine = (line) => {

return {
name: parsedLine[0],
stmts: parsedLine[1].trimStart(),
miss: parsedLine[2].trimStart(),
cover: parsedLine[parsedLine.length - 1].trimStart(),
stmts: parsedLine[1].trim(),
miss: parsedLine[2].trim(),
cover: parsedLine[parsedLine.length - 1].trim(),
};
};

Expand Down