-
-
Notifications
You must be signed in to change notification settings - Fork 173
Open
Labels
Description
To get the default base branch name we execute:
git symbolic-ref refs/remotes/origin/HEAD'This definitely fits most cases and the user can always specify their own so this issue is more of a QoL for edge cases.
The issue:
- A different remote than
originmay be configured (e.g.upstream, which is commonly used in forks). - Multiple remotes may be configured.
The branch the user is one may have a default branch it tracks hence we could figure that out:
git rev-parse --abbrev-ref --symbolic-full-name @{upstream}However, especially in the CI, it is in a detached state hence this won't work. This can be manually configured:
GitHub Actions:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # Check out the actual branch, not detached HEADGitLab CI:
variables:
GIT_STRATEGY: clone
GIT_CHECKOUT: "true"And then:
git checkout -B $CI_COMMIT_REF_NAME
git branch --set-upstream-to=origin/$CI_COMMIT_REF_NAMETo investigate if there are any actionables here to improve the user experience. A non-exhaustive list of points to explore:
-better defaults
- more fallback
- nicer failure message
- documentation.