Skip to content

Commit

Permalink
fix: Grammar for codecov comment when missing coverage (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-sentry authored and adrian-codecov committed Jun 8, 2024
1 parent 156e5a3 commit e5ce880
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
3 changes: 2 additions & 1 deletion services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ async def do_write_section(self, comparison, diff, changes, links, behind_by=Non
misses_and_partials = None
patch_coverage = None
if misses_and_partials:
ln_text = "lines" if misses_and_partials > 1 else "line"
yield (
f"Attention: Patch coverage is `{patch_coverage}%` with `{misses_and_partials} lines` in your changes are missing coverage. Please review."
f"Attention: Patch coverage is `{patch_coverage}%` with `{misses_and_partials} {ln_text}` in your changes missing coverage. Please review."
)
else:
yield "All modified and coverable lines are covered by tests :white_check_mark:"
Expand Down
3 changes: 2 additions & 1 deletion services/notification/notifiers/mixins/message/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def header_lines(self, comparison: ComparisonProxy, diff, settings) -> List[str]
misses_and_partials = None
patch_coverage = None
if misses_and_partials:
ln_text = "lines" if misses_and_partials > 1 else "line"
lines.append(
f"Attention: Patch coverage is `{patch_coverage}%` with `{misses_and_partials} lines` in your changes are missing coverage. Please review."
f"Attention: Patch coverage is `{patch_coverage}%` with `{misses_and_partials} {ln_text}` in your changes missing coverage. Please review."
)
else:
lines.append(
Expand Down
6 changes: 3 additions & 3 deletions services/notification/notifiers/tests/unit/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ async def test_build_default_payload(
"text": "\n".join(
[
f"## [Codecov](test.example.br/gh/test_build_default_payload/{repo.name}/pull/{sample_comparison.pull.pullid}?dropdown=coverage&src=pr&el=h1) Report",
"Attention: Patch coverage is `66.66667%` with `1 lines` in your changes are missing coverage. Please review.",
"Attention: Patch coverage is `66.66667%` with `1 line` in your changes missing coverage. Please review.",
f"> Project coverage is 60.00%. Comparing base [(`{base_commit.commitid[:7]}`)](test.example.br/gh/test_build_default_payload/{repo.name}/commit/{base_commit.commitid}?dropdown=coverage&el=desc) to head [(`{head_commit.commitid[:7]}`)](test.example.br/gh/test_build_default_payload/{repo.name}/commit/{head_commit.commitid}?dropdown=coverage&el=desc)."
f"",
f"",
Expand Down Expand Up @@ -1551,7 +1551,7 @@ async def test_build_default_payload_with_flags(
"text": "\n".join(
[
f"## [Codecov](test.example.br/gh/test_build_default_payload_with_flags/{repo.name}/pull/{sample_comparison.pull.pullid}?dropdown=coverage&src=pr&el=h1) Report",
"Attention: Patch coverage is `66.66667%` with `1 lines` in your changes are missing coverage. Please review.",
"Attention: Patch coverage is `66.66667%` with `1 line` in your changes missing coverage. Please review.",
f"> Project coverage is 60.00%. Comparing base [(`{base_commit.commitid[:7]}`)](test.example.br/gh/test_build_default_payload_with_flags/{repo.name}/commit/{base_commit.commitid}?dropdown=coverage&el=desc) to head [(`{head_commit.commitid[:7]}`)](test.example.br/gh/test_build_default_payload_with_flags/{repo.name}/commit/{head_commit.commitid}?dropdown=coverage&el=desc)."
f"",
f"",
Expand Down Expand Up @@ -1595,7 +1595,7 @@ async def test_build_default_payload_with_flags_and_footer(
"text": "\n".join(
[
f"## [Codecov](test.example.br/gh/{test_name}/{repo.name}/pull/{sample_comparison.pull.pullid}?dropdown=coverage&src=pr&el=h1) Report",
"Attention: Patch coverage is `66.66667%` with `1 lines` in your changes are missing coverage. Please review.",
"Attention: Patch coverage is `66.66667%` with `1 line` in your changes missing coverage. Please review.",
f"> Project coverage is 60.00%. Comparing base [(`{base_commit.commitid[:7]}`)](test.example.br/gh/test_build_default_payload_with_flags_and_footer/{repo.name}/commit/{base_commit.commitid}?dropdown=coverage&el=desc) to head [(`{head_commit.commitid[:7]}`)](test.example.br/gh/test_build_default_payload_with_flags_and_footer/{repo.name}/commit/{head_commit.commitid}?dropdown=coverage&el=desc).",
f"",
f"| [Files](test.example.br/gh/{test_name}/{repo.name}/pull/{sample_comparison.pull.pullid}?dropdown=coverage&src=pr&el=tree) | Coverage Δ | Complexity Δ | |",
Expand Down
Loading

0 comments on commit e5ce880

Please sign in to comment.