Skip to content

Commit 44f4df0

Browse files
authored
Merge pull request #424 from ollaw/main
2 parents 0503430 + 49b1a75 commit 44f4df0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

coverage_comment/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ def clean_github_output(cls, value: str) -> pathlib.Path:
125125
@property
126126
def GITHUB_PR_NUMBER(self) -> int | None:
127127
# "refs/pull/2/merge"
128-
if "pull" in self.GITHUB_REF:
128+
if self.GITHUB_REF.startswith("refs/pull"):
129129
return int(self.GITHUB_REF.split("/")[2])
130130
return None
131131

132132
@property
133133
def GITHUB_BRANCH_NAME(self) -> str | None:
134134
# "refs/heads/my_branch_name"
135-
if "heads" in self.GITHUB_REF:
135+
if self.GITHUB_REF.startswith("refs/heads"):
136136
return self.GITHUB_REF.split("/", 2)[2]
137137
return None
138138

tests/unit/test_settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def _(**kwargs):
127127
"github_ref, github_pr_number",
128128
[
129129
("foo", None),
130+
("refs/heads/branch-with-pull", None),
131+
("refs/tags/tag-with-pull", None),
130132
("refs/pull/2/merge", 2),
131133
],
132134
)
@@ -138,6 +140,8 @@ def test_config__GITHUB_PR_NUMBER(config, github_ref, github_pr_number):
138140
"github_ref, github_branch_name",
139141
[
140142
("refs/pull/2/merge", None),
143+
("refs/pull/2/head", None),
144+
("refs/tags/tag-with-heads", None),
141145
("refs/heads/a/b", "a/b"),
142146
],
143147
)

0 commit comments

Comments
 (0)