Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.83

- Fixed branch detection in detached-HEAD CI checkouts. When `git name-rev --name-only HEAD` returned an output with a suffix operator (e.g. `remotes/origin/master~1`, `master^0`), the `~N`/`^N` was previously passed through as the branch name and rejected by the Socket API as an invalid Git ref. The suffix is now stripped before the prefix split, producing the bare branch name.

## 2.2.71

- Added `strace` to the Docker image for debugging purposes.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "socketsecurity"
version = "2.2.82"
version = "2.2.83"
requires-python = ">= 3.11"
license = {"file" = "LICENSE"}
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = 'socket.dev'
__version__ = '2.2.82'
__version__ = '2.2.83'
USER_AGENT = f'SocketPythonCLI/{__version__}'
6 changes: 6 additions & 0 deletions socketsecurity/core/git_interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import urllib.parse
import os

Expand Down Expand Up @@ -108,6 +109,11 @@ def __init__(self, path: str):
# Try git name-rev first (most reliable for detached HEAD)
result = self.repo.git.name_rev('--name-only', 'HEAD')
if result and result != 'undefined':
# Strip name-rev suffix operators (~N, ^N, or combinations
# like master~3^2). These characters are forbidden in git
# ref names, so cutting at the first occurrence can never
# truncate a real branch name.
result = re.split(r'[~^]', result, maxsplit=1)[0]
# Clean up the result (remove any prefixes like 'remotes/origin/')
git_detected_branch = result.split('/')[-1]
log.debug(f"Branch detected from git name-rev: {git_detected_branch}")
Expand Down
Loading