twolfson / sexy-bash-prompt

Bash prompt with colors, git statuses, and git branches.
MIT License
1.14k stars 154 forks source link

Compute remote and tracking branch names #69

Closed abhijit86k closed 7 years ago

abhijit86k commented 7 years ago

Do not assume remote to be called "origin" but use the git for-each-ref command to get the explicit remote ref name for the current working branch.

rpdelaney commented 7 years ago

For consistency, please use the bash-style double brackets [[ for tests (rather than single brackets).

abhijit86k commented 7 years ago

Ok looks like I botched something in that last commit.

twolfson commented 7 years ago

Thanks for being so responsive on this PR. It's looking better but we are still missing a fallback and some tests =/

twolfson commented 7 years ago

Alright, I poked around at things and was unable to find out why the tests were breaking. I went to git-config for resolving remote and that seems to work:

https://github.com/twolfson/sexy-bash-prompt/compare/0.26.7...dev/match.tracking.branch

Can you please update to the linked code and remove the fallback logic?

Attribution to Package Control for original code:

https://github.com/wbond/package_control/blob/3.2.1/package_control/upgraders/git_upgrader.py#L57-L63

abhijit86k commented 7 years ago

I merged in the changes from 0.26.7...dev/match.tracking.branch . The problem is that the prompt keeps indicating unpushed changes, even when there is no remote to push to. Here's a little snippet to show the problem.

twolfson commented 7 years ago

It's expected behavior to show unpushed changes when no remote is set. It boils down to personal preference and we've assumed that people would rather know they haven't pushed changes in all cases (e.g. to anywhere or a specific server)

abhijit86k commented 7 years ago

I guess you can then close the PR and merge the code in. As for the part about personal preference, I believe thats a (good) side-effect of git allowing diverse workflows - so I'm just going to have a slightly different version in my fork of the repo! :) Thanks again for being so patient.

twolfson commented 7 years ago

Yep, just waiting for @rpdelaney on #70. Thanks for your work on this =)

twolfson commented 7 years ago

This has been merged/released with #70 for corrections/tests in 0.27.0. Thanks for your help again!