Skip to content

Commit

Permalink
chore: update message when PR head differs
Browse files Browse the repository at this point in the history
ticket: codecov/engineering-team#1595

Change message when the HEAD of the PR we have is not up to date with
the PR's most recent head.
Makes the message more actionable.
Check ticket for further info.
  • Loading branch information
giovanni-guidini committed May 15, 2024
1 parent 3d44c4e commit 863f10c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 7 additions & 6 deletions services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,14 @@ async def do_write_section(self, comparison, diff, changes, links, behind_by=Non
),
)
yield ("")
pull_head = comparison.enriched_pull.provider_pull["head"]["commitid"][:7]
current_head = comparison.head.commit.commitid[:7]
yield (
"> :exclamation: Current head {current_head} differs from pull request most recent head {pull_head}. Consider uploading reports for the commit {pull_head} to get more accurate results".format(
pull_head=comparison.enriched_pull.provider_pull["head"][
"commitid"
][:7],
current_head=comparison.head.commit.commitid[:7],
)
f"> :exclamation: **Current head {current_head} differs from pull request most recent head {pull_head}**"
)
yield ("> ")
yield (
f"> Please [upload](https://docs.codecov.com/docs/codecov-uploader) reports for the commit {pull_head} to get more accurate results."
)

if self.settings.get("show_critical_paths"):
Expand Down
8 changes: 6 additions & 2 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4723,7 +4723,9 @@ async def test_build_message_head_and_pull_head_differ_new_layout(
f"Attention: Patch coverage is `66.66667%` with `1 lines` in your changes are missing coverage. Please review.",
f"> Project coverage is 60.00%. Comparing base [(`{comparison.project_coverage_base.commit.commitid[:7]}`)](test.example.br/gh/{repository.slug}/commit/{comparison.project_coverage_base.commit.commitid}?dropdown=coverage&el=desc) to head [(`{comparison.head.commit.commitid[:7]}`)](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=desc).",
f"",
f"> :exclamation: Current head {comparison.head.commit.commitid[:7]} differs from pull request most recent head {comparison.enriched_pull.provider_pull['head']['commitid'][:7]}. Consider uploading reports for the commit {comparison.enriched_pull.provider_pull['head']['commitid'][:7]} to get more accurate results",
f"> :exclamation: **Current head {comparison.head.commit.commitid[:7]} differs from pull request most recent head {comparison.enriched_pull.provider_pull['head']['commitid'][:7]}**",
f"> ",
f"> Please [upload](https://docs.codecov.com/docs/codecov-uploader) reports for the commit {comparison.enriched_pull.provider_pull['head']['commitid'][:7]} to get more accurate results.",
f"",
f"<details><summary>Additional details and impacted files</summary>\n",
f"",
Expand Down Expand Up @@ -4798,7 +4800,9 @@ async def test_build_message_head_and_pull_head_differ_with_components(
f"Attention: Patch coverage is `66.66667%` with `1 lines` in your changes are missing coverage. Please review.",
f"> Project coverage is 60.00%. Comparing base [(`{comparison.project_coverage_base.commit.commitid[:7]}`)](test.example.br/gh/{repository.slug}/commit/{comparison.project_coverage_base.commit.commitid}?dropdown=coverage&el=desc) to head [(`{comparison.head.commit.commitid[:7]}`)](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=desc).",
f"",
f"> :exclamation: Current head {comparison.head.commit.commitid[:7]} differs from pull request most recent head {comparison.enriched_pull.provider_pull['head']['commitid'][:7]}. Consider uploading reports for the commit {comparison.enriched_pull.provider_pull['head']['commitid'][:7]} to get more accurate results",
f"> :exclamation: **Current head {comparison.head.commit.commitid[:7]} differs from pull request most recent head {comparison.enriched_pull.provider_pull['head']['commitid'][:7]}**",
f"> ",
f"> Please [upload](https://docs.codecov.com/docs/codecov-uploader) reports for the commit {comparison.enriched_pull.provider_pull['head']['commitid'][:7]} to get more accurate results.",
f"",
f"<details><summary>Additional details and impacted files</summary>\n",
f"",
Expand Down

0 comments on commit 863f10c

Please sign in to comment.