Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: enhance branch detection with CI support and robust fallbacks #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
dacoburn merged 1 commit into main from doug/fix-branch-detection
Jul 25, 2025

Conversation

@dacoburn
Copy link
Collaborator

@dacoburn dacoburn commented Jul 25, 2025

With the latest update the automatic detection of the branch information in a detached head state was not being picked up like for Gitlab.

Root Cause

Gitlab variables and proper git detection for detached head state were not being done.

Fix

  • Add comprehensive CI environment variable support for GitLab, GitHub, and Bitbucket
  • Implement priority system: CLI args → CI variables → git properties → defaults
  • Add robust fallback chain for branch detection in detached HEAD scenarios
  • Replace hard failures with sensible defaults (socket-default-repo, socket-default-branch)
  • Fix GitLab CI branch detection issue where branch was showing as None
  • Support additional commit SHA sources (CI_COMMIT_SHA, BITBUCKET_COMMIT)
  • Enhance default branch detection logic for all CI platforms
  • Improve error handling and logging throughout git interface

Resolves GitLab pipeline branch detection failures and ensures CLI never fails due to missing repository or branch information.

Public Changelog

  • Improved branch detection in CI environments to properly handle GitLab CI, GitHub Actions, and Bitbucket Pipelines environment variables
  • Fixed branch detection showing "None" in GitLab CI pipelines by implementing proper fallback logic
  • Enhanced repository and branch detection with priority system: CLI arguments → CI variables → Git properties → defaults
  • Added robust fallback system with default values ("socket-default-repo", "socket-default-branch") to prevent CLI failures
  • Improved detached HEAD branch detection using git name-rev and describe commands for more accurate results

- Add comprehensive CI environment variable support for GitLab, GitHub, and Bitbucket
- Implement priority system: CLI args → CI variables → git properties → defaults
- Add robust fallback chain for branch detection in detached HEAD scenarios
- Replace hard failures with sensible defaults (socket-default-repo, socket-default-branch)
- Fix GitLab CI branch detection issue where branch was showing as None
- Support additional commit SHA sources (CI_COMMIT_SHA, BITBUCKET_COMMIT)
- Enhance default branch detection logic for all CI platforms
- Improve error handling and logging throughout git interface
Resolves GitLab pipeline branch detection failures and ensures CLI never fails
due to missing repository or branch information.
@dacoburn dacoburn requested a review from a team as a code owner July 25, 2025 17:11
@dacoburn dacoburn removed the request for review from a team July 25, 2025 17:11
@dacoburn dacoburn added the Product Changelog New features for the public changelog label Jul 25, 2025
Copy link

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.1.27.dev1

Docker image: socketdev/cli:pr-104

@dacoburn dacoburn merged commit c28a138 into main Jul 25, 2025
6 checks passed
@dacoburn dacoburn deleted the doug/fix-branch-detection branch July 25, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bcomnes bcomnes bcomnes approved these changes

@jhiesey jhiesey Awaiting requested review from jhiesey jhiesey is a code owner automatically assigned from SocketDev/eng

@alxhotel alxhotel Awaiting requested review from alxhotel alxhotel is a code owner automatically assigned from SocketDev/eng

Assignees

No one assigned

Labels

Product Changelog New features for the public changelog

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /