Skip to content

Commit a5b1d1f

Browse files
committed
fix: handle detached HEAD state in repository scanner
- Wrap repo.active_branch.name in try/except - Fallback to 'HEAD' when in detached HEAD state - Fixes CI failure where GitHub Actions checks out in detached HEAD Error: TypeError: HEAD is a detached symbolic reference Occurs in CI environments during git checkout
1 parent df272f2 commit a5b1d1f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/agentready/services/scanner.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,14 @@ def _build_repository_model(self, verbose: bool = False) -> Repository:
163163
# Git metadata
164164
repo = git.Repo(self.repository_path)
165165
name = self.repository_path.name
166-
branch = repo.active_branch.name
166+
167+
# Handle detached HEAD state (e.g., in CI/CD)
168+
try:
169+
branch = repo.active_branch.name
170+
except TypeError:
171+
# Detached HEAD - use commit hash or "HEAD"
172+
branch = "HEAD"
173+
167174
commit_hash = repo.head.commit.hexsha
168175

169176
# Get remote URL (if available)

0 commit comments

Comments
 (0)