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

Show dashes (-) instead of 0 in the table #443

Merged
merged 8 commits into from Dec 12, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/task/src/pullRequests/pullRequestComments.ts
Expand Up @@ -202,6 +202,11 @@ export default class PullRequestComments {
surround = '**'
}

return `${surround}${title}${surround}|${surround}${metric.toLocaleString()}${surround}\n`
let metricString = metric.toLocaleString()
if (metricString === '0') {
metricString = '-'
}

return `${surround}${title}${surround}|${surround}${metricString}${surround}\n`
}
}
10 changes: 5 additions & 5 deletions src/task/tests/pullRequests/pullRequestComments.spec.ts
Expand Up @@ -359,11 +359,11 @@ describe('pullRequestComments.ts', (): void => {
'✔ **Thanks for adding tests.**\n' +
'||Lines\n' +
'-|-:\n' +
`Product Code|${code[0].toLocaleString()}\n` +
`Test Code|${code[1].toLocaleString()}\n` +
`**Subtotal**|**${code[2].toLocaleString()}**\n` +
`Ignored Code|${code[3].toLocaleString()}\n` +
`**Total**|**${code[4].toLocaleString()}**\n` +
`Product Code|${code[0].toLocaleString() === '0' ? '-' : code[0].toLocaleString()}\n` +
`Test Code|${code[1].toLocaleString() === '0' ? '-' : code[1].toLocaleString()}\n` +
`**Subtotal**|**${code[2].toLocaleString() === '0' ? '-' : code[2].toLocaleString()}**\n` +
`Ignored Code|${code[3].toLocaleString() === '0' ? '-' : code[3].toLocaleString()}\n` +
`**Total**|**${code[4].toLocaleString() === '0' ? '-' : code[4].toLocaleString()}**\n` +
'\n' +
'[Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs!](https://aka.ms/PRMetrics/Comment)')
verify(logger.logDebug('* PullRequestComments.getMetricsComment()')).once()
Expand Down