Skip to content

Commit

Permalink
Addressing the issue of PRs not targetting the default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim committed Sep 10, 2023
1 parent 492b997 commit cdf71fa
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions coverage_comment/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,17 @@ def process_pr(
base_ref=base_ref, coverage_path=config.COVERAGE_PATH
)

previous_coverage_data_file = storage.get_datafile_contents(
github=gh,
repository=config.GITHUB_REPOSITORY,
branch=config.COVERAGE_DATA_BRANCH,
)
# It only really makes sense to display a comparison with the previous
# coverage if the PR target is the branch in which the coverage data is
# stored, e.g. the default branch.
previous_coverage_data_file = None
if base_ref == repo_info.default_branch:
previous_coverage_data_file = storage.get_datafile_contents(
github=gh,
repository=config.GITHUB_REPOSITORY,
branch=config.COVERAGE_DATA_BRANCH,
)

previous_coverage = None
if previous_coverage_data_file:
previous_coverage = files.parse_datafile(contents=previous_coverage_data_file)
Expand Down

0 comments on commit cdf71fa

Please sign in to comment.