Skip to content

Commit f91653f

Browse files
Jonathan Muchaclaude
andcommitted
fix: add ref and pipeline_id to commit status payload
GitLab uses (sha, name, ref) as unique key. Without ref, re-runs fail with "name has already been taken". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6946be4 commit f91653f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

socketsecurity/core/scm/gitlab.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ def set_commit_status(self, state: str, description: str, target_url: str = '')
282282
"context": "socket-security",
283283
"description": description,
284284
}
285+
if self.config.mr_source_branch:
286+
payload["ref"] = self.config.mr_source_branch
287+
pipeline_id = os.getenv("CI_PIPELINE_ID")
288+
if pipeline_id:
289+
payload["pipeline_id"] = int(pipeline_id)
285290
if target_url:
286291
payload["target_url"] = target_url
287292
try:

tests/unit/test_gitlab_commit_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def test_calls_correct_url_and_json_payload(self, mock_post):
4545
"state": "success",
4646
"context": "socket-security",
4747
"description": "No blocking issues",
48+
"ref": "feature",
4849
"target_url": "https://app.socket.dev/report/123",
4950
},
5051
headers=config.headers,

0 commit comments

Comments
 (0)