Skip to content

Commit

Permalink
Merge pull request #424 from ollaw/main
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim authored Jun 6, 2024
2 parents 0503430 + 49b1a75 commit 44f4df0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coverage_comment/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ def clean_github_output(cls, value: str) -> pathlib.Path:
@property
def GITHUB_PR_NUMBER(self) -> int | None:
# "refs/pull/2/merge"
if "pull" in self.GITHUB_REF:
if self.GITHUB_REF.startswith("refs/pull"):
return int(self.GITHUB_REF.split("/")[2])
return None

@property
def GITHUB_BRANCH_NAME(self) -> str | None:
# "refs/heads/my_branch_name"
if "heads" in self.GITHUB_REF:
if self.GITHUB_REF.startswith("refs/heads"):
return self.GITHUB_REF.split("/", 2)[2]
return None

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def _(**kwargs):
"github_ref, github_pr_number",
[
("foo", None),
("refs/heads/branch-with-pull", None),
("refs/tags/tag-with-pull", None),
("refs/pull/2/merge", 2),
],
)
Expand All @@ -138,6 +140,8 @@ def test_config__GITHUB_PR_NUMBER(config, github_ref, github_pr_number):
"github_ref, github_branch_name",
[
("refs/pull/2/merge", None),
("refs/pull/2/head", None),
("refs/tags/tag-with-heads", None),
("refs/heads/a/b", "a/b"),
],
)
Expand Down

0 comments on commit 44f4df0

Please sign in to comment.