Fix git get_default_branch remote - #2394
Open
shinenelson wants to merge 6 commits into
Open
Conversation
Instead of assuming the default remote is always 'origin', the function now: - Checks if origin exists and uses it as the default remote - Falls back to the first available remote if origin doesn't exist - Properly detects the default branch for the selected remote
Tests verify that get_default_branch: - Returns the correct branch when origin exists - Falls back to the first available remote when origin doesn't exist - Handles missing remotes gracefully - Properly strips the remote prefix from the symbolic ref - Prefers origin when multiple remotes are available
Annotate test/aliases/git.bats with proper SPDX copyright and license information for legal compliance.
Quote the variable expansion inside the parameter expansion pattern to satisfy shellcheck SC2295 requirements.
Include the aliases directory in the default test discovery so that test/run without arguments includes alias tests.
Contributor
Author
|
Edit : It seems a re-run of the CI checks have fixed the issue. Maybe GitHub Actions did not like the slavery references. |
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.
Description
This change-set improves the get_default_branch function in
git.aliases.bash to pick any configured remote if origin is
unavailable.
Motivation and Context
Previously, the get_default_branch function assumed 'origin' as the
remote and tried to get the symbolic-ref of that remote. For people
whose defaultRemoteName is custom and not 'origin', the function is
broken which in turn breaks all aliases calling the function.
Instead of assuming the default remote is always 'origin', the
function now:
How Has This Been Tested?
There were no tests that existed because this was a function within
aliases. New tests has been added for the function.
Types of changes
Checklist:
clean_files.txtand formatted it usinglint_clean_files.sh.