-
Notifications
You must be signed in to change notification settings - Fork 624
feat(baseBranch): improve shortName
calculation
#8608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(baseBranch): improve shortName
calculation
#8608
Conversation
Improve the `shortName` calculation to handle various Git branch name formats, including remote branches and local branches. This ensures the branch name is always returned in a consistent format, without any prefixes like "refs/remotes/", "refs/heads/", or the remote name.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@matthewevans is attempting to deploy a commit to the GitButler Team on Vercel. A member of the Team first needs to authorize it. |
That's great, thanks so much! It would be lovely if this could fix the linked PR-creation issue. CC @estib-vega . |
Forgive me if I'm misunderstanding, but the new
|
@matthewevans another great contribution! |
We should probably use the rust function |
{ | ||
branchName: 'refs/remotes/origin/feature/foo', | ||
remoteName: 'origin', | ||
expected: 'feature/foo', | ||
description: 'full ref with remote' | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have some horror of a scenario where you have a remote called origin/feature
and the branch name is only foo
🧢 Changes
shortName
getter tolastPathComponent
to better reflect its actual functionalityshortName
that properly handles Git reference formatsrefs/remotes/remoteName/
,remoteName/
,refs/heads/
)☕️ Reasoning
The previous
shortName
implementation only extracted the last path component of a branch name without handling Git's reference formats properly. The new implementation normalizes branch names by intelligently stripping Git-specific prefixes based on context (remote vs. local), resulting in more consistent and user-friendly branch name representation throughout the application.Further context:
origin/release/2025.18
. When I tried to create a PR it was attempting to use2025.18
as the base branch. GitHub refused and GitButler showed an error. This fix allowed me to successfully create the PR. I also invested the other locations that leveragedshortName
and they all appeared to use it in a context where they would expect the full branch name.🎫 Affected issues
Fixes: #8596 (I believe – I was receiving the same error in my repro case)