Skip to content

Conversation

runningcode
Copy link
Contributor

@runningcode runningcode commented Sep 19, 2025

Summary

Implements GitHub Actions-aware base branch detection that works in detached HEAD state

Problem

In GitHub Actions pull request workflows, repositories are checked out in detached HEAD state, causing the existing git_repo_base_ref() function to fail when trying to detect the base branch for merge-base calculations.

Solution

  • New Function: Added get_github_base_ref() that reads the GITHUB_BASE_REF environment variable
  • Smarter Detection Chain: GitHub Actions detection now takes priority over git introspection:
    1. Explicit --base-ref argument
    2. GitHub Actions environment variables (fast, reliable)
    3. Git repository introspection (fallback)
    4. None (final fallback)

This leverages the GitHub Actions context variables that are automatically set in pull request workflows, specifically GITHUB_BASE_REF which contains the target branch of the pull request.

🤖 Generated with Claude Code

Implement GitHub Actions-aware base branch detection that works in
detached HEAD states commonly found in CI/CD environments.

Changes:
- Add get_github_base_ref() function to read GITHUB_BASE_REF env var
- Prioritize GitHub Actions env vars over git introspection for reliability
- Update test snapshots to remove base branch detection warning
- Maintain backward compatibility with existing git-based detection

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

linear bot commented Sep 19, 2025

@runningcode runningcode marked this pull request as ready for review September 19, 2025 16:51
@runningcode runningcode requested review from a team and szokeasaurusrex as code owners September 19, 2025 16:51
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for the change! I have a quick question though about precedence

Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification 🚀

@runningcode runningcode merged commit b259595 into master Sep 23, 2025
25 checks passed
@runningcode runningcode deleted the no/eme-320-github-actions-base-branch branch September 23, 2025 08:17
szokeasaurusrex added a commit that referenced this pull request Sep 23, 2025
This reverts commit b259595 from #2776

This change is causing CI to fail on `master`. As I would like to
release Sentry CLI, we need to revert this to unblock the release
process.
runningcode added a commit that referenced this pull request Sep 23, 2025
runningcode added a commit that referenced this pull request Sep 24, 2025
## Summary

Reverts commit c0beb47 to restore the
GitHub Actions base branch detection functionality that was previously
implemented in #2776.

## Background

The original GHA base branch detection was reverted in #2789 due to CI
failures on master. However, those test failures were actually resolved
separately in #2791 by adding `--log-level=error` to suppress warning
messages in the integration tests.

## Changes

This PR restores:
- `get_github_base_ref()` function in `src/utils/vcs.rs` that detects
base branch from `GITHUB_BASE_REF` environment variable
- Integration of GHA base branch detection in the build upload command
logic
- Tests for the `get_github_base_ref()` function

The test failures that caused the original revert have been resolved by
the test fixes in #2791, so this functionality can now be safely
restored.

🤖 Generated with [Claude Code](https://claude.ai/code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants