Handle slashes in branch name when shortening remote#39
Open
NAR8789 wants to merge 14 commits intostarcraftman:masterfrom
Open
Handle slashes in branch name when shortening remote#39NAR8789 wants to merge 14 commits intostarcraftman:masterfrom
NAR8789 wants to merge 14 commits intostarcraftman:masterfrom
Conversation
ad65e62 to
f6507af
Compare
dbc1802 to
7c42a6f
Compare
7c42a6f to
a89fc12
Compare
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.
PR Main Content
Bugfix: When the branch name contains slashes, setting
ZSH_GIT_PROMPT_SHOW_UPSTREAM=2did not produce the expected behavior of upstream name getting shortened.For example, with my current branch name of
fix/handle-slashes-in-branch-name, and an upstream oforigin/fix/handle-slashes-in-branch-name, I'd expect a prompt likebut I was actually seeing
Root cause: original shortening process split on slashes and tried to match last component to branch name. Due to splitting on slashes, last component would be a suffix of branch name, and would not match.
Fix: Use suffix removal instead of splitting on slashes.
Extra Bits
I've also added tests for the shell code, and made a minor fix to make
flake8pass. These are not technically part of the above, so I can pull these into separate PRs if you prefer.Tests
I've brought in shunit2 to test the zsh parts.
In the individual tests, I've written expectations using the fully-rendered version of the prompt, complete with ANSI sequences. This renders nicely if you
catorless -Rthe file, but as far as I know all text editors will render the ANSI control chars as garbage.I decided to include the ANSI garbage because
git_super_statusalready outputs ANSI codes even before prompt escapes get interpreted, so to some degree having garbagy expect strings is unavoidable. Going with fully rendered strings means they at least display nicely inless -RFlake8 Fix
Flake8 3.6.0 does not like line breaks anywhere around operators. This is causing travis builds to always fail. Since
W504is the current recommendation. I've disabledW503.Background
I tend to have slashes in my branch names at work, because we use a convention of prefixing feature branches with
feature/, and fixes withhotfix/.