Skip to content

Commit

Permalink
Don't crash on pushing when pushing on something else than a branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim committed Oct 11, 2023
1 parent 70b2d8a commit f86c19e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion coverage_comment/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ def process_pr(
) -> int:
log.info("Generating comment for PR")

if not config.GITHUB_PR_NUMBER and not config.GITHUB_BRANCH_NAME:
log.info(

Check warning on line 116 in coverage_comment/main.py

View workflow job for this annotation

GitHub Actions / Run tests & display coverage

This line has no coverage
"This worflow is not triggered on a pull_request event, "
"nor on a push event on a branch. Consequently, there's nothing to do. "
"Exiting."
)
return 0

Check warning on line 121 in coverage_comment/main.py

View workflow job for this annotation

GitHub Actions / Run tests & display coverage

This line has no coverage

_, coverage = coverage_module.get_coverage_info(
merge=config.MERGE_COVERAGE_FILES,
coverage_path=config.COVERAGE_PATH,
Expand Down Expand Up @@ -177,7 +185,6 @@ def process_pr(
if pr_number is None:
# If we don't have a PR number, we're launched from a push event,
# so we need to find the PR number from the branch name
assert config.GITHUB_BRANCH_NAME
try:
pr_number = github.find_pr_for_branch(
github=gh,
Expand Down

0 comments on commit f86c19e

Please sign in to comment.