Skip to content

Commit 13567be

Browse files
committedFeb 27, 2025
feat(junit): return ref head name
Change-Id: Ia7d95b17f09bbde2531a4fb6fafb65d4cfb729af
1 parent 847c989 commit 13567be

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed
 

‎mergify_cli/ci/detector.py

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ def get_job_name() -> str | None:
2828
return None
2929

3030

31+
def get_head_ref_name() -> str | None:
32+
match get_ci_provider():
33+
case "github_actions":
34+
return os.getenv("GITHUB_HEAD_REF") or os.getenv("GITHUB_REF")
35+
case "circleci":
36+
return os.getenv("CIRCLE_BRANCH")
37+
case _:
38+
return None
39+
40+
3141
def get_github_actions_head_sha() -> str | None:
3242
if os.getenv("GITHUB_EVENT_NAME") == "pull_request":
3343
# NOTE(leo): we want the head sha of pull request

‎mergify_cli/ci/junit.py

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ async def junit_to_spans(
7676
if (head_revision := (await detector.get_head_sha())) is not None:
7777
resource_attributes[vcs_attributes.VCS_REF_HEAD_REVISION] = head_revision
7878

79+
if (head_ref_name := detector.get_head_ref_name()) is not None:
80+
resource_attributes[vcs_attributes.VCS_REF_HEAD_NAME] = head_ref_name
81+
7982
if (provider := detector.get_ci_provider()) is not None:
8083
resource_attributes["cicd.provider.name"] = provider
8184

0 commit comments

Comments
 (0)
Failed to load comments.