Skip to content

Conversation

runningcode
Copy link
Contributor

@runningcode runningcode commented Sep 25, 2025

Summary

Automatically fetch base SHA for the build upload command when running in GitHub Actions pull request workflows. This eliminates the need to manually specify --base-sha in most cases.

How it works

Priority order:

  1. User-provided value takes highest priority (--base-sha argument)
  2. Automatic detection from GITHUB_EVENT_PATH payload (/pull_request/base/sha) when running in GitHub Actions PR workflows
  3. Graceful fallback when no base SHA is available (returns error from find_base_sha())

Resolves: EME-349

🤖 Generated with Claude Code

Copy link

linear bot commented Sep 25, 2025

Add automatic base SHA detection for the build upload command when running
in GitHub Actions pull request workflows. This eliminates the need to
manually specify --base-sha in most cases.

Changes:
- Add extract_pr_base_sha_from_event() helper function
- Add find_base_sha() function following the same pattern as find_head()
- Update build upload command to use automatic base SHA detection
- Add comprehensive tests for the new functionality

Resolves EME-349

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

Co-Authored-By: Claude <noreply@anthropic.com>
@runningcode runningcode force-pushed the no/nelsonosacky/eme-349-fetch-base-sha-automatically-in-sentry-cli-for-github branch from e6ebe8a to 96aace1 Compare September 25, 2025 06:25
@runningcode runningcode marked this pull request as ready for review September 25, 2025 06:25
@runningcode runningcode requested review from a team and szokeasaurusrex as code owners September 25, 2025 06:25
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.

Looks good, see comment before merge

@runningcode runningcode merged commit 5217470 into master Sep 26, 2025
42 of 44 checks passed
@runningcode runningcode deleted the no/nelsonosacky/eme-349-fetch-base-sha-automatically-in-sentry-cli-for-github branch September 26, 2025 05:33
runningcode added a commit that referenced this pull request Sep 29, 2025
…2805)

## Summary
- Add `get_github_head_ref()` function to automatically detect head
branch from GitHub Actions environment variables
- Integrate with upload command fallback chain to resolve detached HEAD
scenarios
- Use `GITHUB_HEAD_REF` for automatic head-ref detection in PR workflows

See context reference:
https://docs.github.com/en/actions/reference/workflows-and-actions/contexts

## Context
Resolves EME-367 - Auto-fetch correct head-ref value in detached HEAD
state using GitHub Actions env variables. Follows the same pattern as
recent work on base SHA auto-fetching (#2799).

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

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds get_github_head_ref() (reads GITHUB_HEAD_REF in pull_request) and
makes build upload prefer it before git head ref to handle detached
HEAD.
> 
> - **Build Upload**:
> - Update `src/commands/build/upload.rs` head-ref resolution to first
use `get_github_head_ref()`; fall back to `git_repo_head_ref`.
> - **VCS Utils**:
> - Add `get_github_head_ref()` to read `GITHUB_HEAD_REF` when
`GITHUB_EVENT_NAME` is `pull_request` with debug logging.
>   - Export and import updated in `utils::vcs` and upload command.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
332fe76. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude <noreply@anthropic.com>
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