fix: handle missing symbolic-ref for default branch detection (fixes #3)#2
Merged
fix: handle missing symbolic-ref for default branch detection (fixes #3)#2
Conversation
Fixes #3 - Replace symbolic-ref based default branch detection with more robust approach - Use current branch when available, fallback to 'main' if not - Fixes 'symbolic-ref refs/remotes/origin/HEAD' error in GitHub Actions environments - Removes complex getDefaultBranch method in favor of simpler validation The issue occurs because GitHub Actions checkout doesn't set up symbolic references properly, causing the action to fail during repository validation. This fix ensures the action works in all GitHub Actions environments while maintaining functionality for repositories with proper git configuration.
5105de5 to
7a868aa
Compare
- Update mocks to use rev-parse --abbrev-ref HEAD instead of symbolic-ref - Add test cases for fallback behavior when branch detection fails - Add test for detached HEAD scenario - All tests now pass with the new implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #3
The action was failing with this error in GitHub Actions environments:
Root Cause
GitHub Actions checkout doesn't automatically set up the symbolic reference
refs/remotes/origin/HEADthat points to the default branch. Thegit symbolic-ref refs/remotes/origin/HEADcommand fails because this reference isn't established during the checkout process.This is a common issue in GitHub Actions environments where repositories are cloned with specific configurations that may not include all traditional git references.
Solution
Changes
validateRepository()method inGitOperationsclassgetDefaultBranch()method with multiple fallback strategiesTesting
Impact
This fix ensures the action works properly in standard GitHub Actions environments where symbolic references may not be set up, while maintaining functionality for repositories with proper git configuration.
References: