Skip to content

fix: handle branch name retrieval in GitHub Actions context#295

Open
rmenner wants to merge 1 commit into
devfrom
rmenner/check-commits/branch-ref
Open

fix: handle branch name retrieval in GitHub Actions context#295
rmenner wants to merge 1 commit into
devfrom
rmenner/check-commits/branch-ref

Conversation

@rmenner

@rmenner rmenner commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Alaska Airlines Pull Request

This pull request updates the logic for determining the current Git branch in gitUtils.ts, specifically to improve compatibility with GitHub Actions. The change ensures that, when running in a GitHub Actions pull request context, the correct branch name is used instead of the detached HEAD reference.

Branch detection improvements for CI:

  • Updated the logic in the Git class to use the GITHUB_HEAD_REF environment variable when running in GitHub Actions, ensuring the correct PR branch name is used instead of the detached HEAD state, which avoids issues with invalid remote-tracking refs.

Checklist:

  • My update follows the CONTRIBUTING guidelines of this project
  • I have performed a self-review of my own update

By submitting this Pull Request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Pull Requests will be evaluated by their quality of update and whether it is consistent with the goals and values of this project. Any submission is to be considered a conversation between the submitter and the maintainers of this project and may require changes to your submission.

Thank you for your submission!

-- Auro Design System Team

Summary by Sourcery

Enhancements:

  • Use the GITHUB_HEAD_REF environment variable in GitHub Actions PR contexts to obtain the actual source branch name instead of relying on detached HEAD metadata.

@rmenner
rmenner requested a review from a team as a code owner May 22, 2026 17:24
@sourcery-ai

sourcery-ai Bot commented May 22, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates Git branch detection in gitUtils.ts to correctly resolve the PR branch name in GitHub Actions, preferring GITHUB_HEAD_REF in CI over the detached HEAD branchLocal() result.

Flow diagram for updated Git branch detection in Git class

flowchart TD
  A[Start determine branch] --> B{sourceBranch provided?}
  B -- Yes --> C[Use sourceBranch]
  B -- No --> D{GITHUB_ACTIONS and GITHUB_HEAD_REF set?}
  D -- Yes --> E[branch = GITHUB_HEAD_REF]
  D -- No --> F[call branchLocal]
  F --> G[branch = branchLocal.current]
  C --> H[Proceed with branch]
  E --> H
  G --> H
Loading

File-Level Changes

Change Details Files
Improve branch resolution logic in CI to use the real PR branch name in GitHub Actions instead of the detached HEAD pseudo-branch.
  • When no sourceBranch is provided, check for GitHub Actions environment with GITHUB_HEAD_REF set before querying git.branchLocal().
  • Use the GITHUB_HEAD_REF environment variable as the branch name in GitHub Actions PR contexts.
  • Fall back to git.branchLocal().current only when GITHUB_HEAD_REF is not available, preserving existing behavior outside GitHub Actions.
src/utils/gitUtils.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

Copy link
Copy Markdown

🚀 PR Release Published! @aurodesignsystem-dev/auro-cli@0.0.0-pr295.0 View on npmjs.com

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider scoping the GitHub Actions override to PR events explicitly (e.g., checking GITHUB_EVENT_NAME === 'pull_request' or similar) so that GITHUB_HEAD_REF is not used unexpectedly in other workflow contexts.
  • You might want to extract the branch resolution logic into a small helper method (e.g., getCurrentBranchName()), which would make the behavior easier to reason about and reuse, and simplify future CI-specific adjustments.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider scoping the GitHub Actions override to PR events explicitly (e.g., checking `GITHUB_EVENT_NAME === 'pull_request'` or similar) so that `GITHUB_HEAD_REF` is not used unexpectedly in other workflow contexts.
- You might want to extract the branch resolution logic into a small helper method (e.g., `getCurrentBranchName()`), which would make the behavior easier to reason about and reuse, and simplify future CI-specific adjustments.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants