Added truncation_length/symbol to git_branch #268
Merged
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.
Added a way to truncate git branches
Description
Git branches can become very long (e.g. gitlab auto-generated branch
names), thus it would be nice to be able to truncate them to keep your
prompt lenght in line.
This patch adds two new options to the git_branch module:
truncate to
branch name was trunctated
To be able to correctly work with UTF-8 graphemes, unicode-segmentation
was added as a dependency.
Motivation and Context
I made this change because we use GitLab, but it's useful in other scenarios as well. If you have an issue on GitLab you can press a button on that issue to automatically create a merge request and a branch for you. However, the pattern for the branch name is
${ticket_nr}_${title}.toLowercase().replaceAll(" ", "_")
.For issue number 1234 and title #1234 "Fix the typo in the about page when you right click something" we get a branch named
1234_fix_the_typo_in_the_about_page_when_you_right_click_something
. Having this in your prompt makes it unusable as it uses up way too much spaceTypes of changes
Screenshots (if appropriate):
How Has This Been Tested?
I think I have a pretty complete testsuite, however I didn't test on any other OS's.
Checklist:
I updated the documentation, but I didn't know how to build it locally so I haven't checked that it's rendered as expected.