-
Notifications
You must be signed in to change notification settings - Fork 132
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
Mark untracked as dirty; fix dirty marker when no HEAD ref #286
Conversation
Hello @spthm, |
110fb5d
to
6a14db4
Compare
3e7972a
to
4f9541d
Compare
Hello @spthm, Your MR fix/finish an incomplete behavior on the git feature, the feature flag, sound superfluous. If we get feedback that it is negatively impacting the speed of the prompt, then we can add a feature flag. Test outputI don't have the permissions to push force the rebase on your repo, so here is the log:
|
b75d013
to
27e7ffa
Compare
@edouard-lopez sorry it took so long to respond. I had misunderstood how the git dirty tests work, thinking each was isolated/running from a fresh directory. I have now fixed the tests so they take account of changes made by other tests. All tests are passing for me locally, $ make build-pure-on FISH_VERSION=3.3.1
...
$ make test-pure-on FISH_VERSION=3.3.1
...
# /tmp/.pure/tests/_pure_prompt_git_dirty.test.fish
ok 140 _pure_prompt_git_dirty: empty repo is not marked as dirty
ok 141 _pure_prompt_git_dirty: untracked files in empty repo marked as dirty
ok 142 _pure_prompt_git_dirty: staged files in empty repo marked as dirty
ok 143 _pure_prompt_git_dirty: clean is not marked as dirty
ok 144 _pure_prompt_git_dirty: untracked files mark git repo as dirty
ok 145 _pure_prompt_git_dirty: staged files mark git repo as dirty
ok 146 _pure_prompt_git_dirty: symbol is colorized
...
1..230
# pass 230
# ok |
da8300b
to
2880052
Compare
This now passes the git dirty prompt tests.
These tests run in sequence in the same directory, they are not isolated. Tests need to take account of changes to the directory state made by previous tests.
25db858
to
ddc3a44
Compare
That's weird, test should have been isolated. I'm adding a call to |
Summary of changes:
HEAD
_pure_prompt_git_dirty
whenHEAD
does and does not existCurrently,
_pure_prompt_git_dirty
does not add the dirty maker for untracked files. The implementation here is as it's done ingit/contrib/completion/git-prompt.sh
.When I went to go add a test for this feature, I discovered it was already there - and passing! This is because the
git diff-index [...] HEAD --
used gives a non-zero exit code whenHEAD
is not present. All repos without aHEAD
are therefore marked as dirty. During testing, the repo does not have aHEAD
.This PR fixes that, falling back to a
git diff --staged
whenHEAD
is not present. It also ~duplicates the existing tests to check the dirty marker works as expected immediately aftergit init
(i.e. noHEAD
) and after an initial commit (i.e. with aHEAD
).To (maybe) clarify things a bit: with the tests in this PR, both
_pure_prompt_git_dirty: empty repo is not marked as dirty
and_pure_prompt_git_dirty: untracked files mark git repo as dirty
fail onmaster
.Wasn't sure if this should be behind a new feature flag (e.g.
pure_untracked_is_dirty
). It is documented/expected behaviour, but this fix might slow down the prompt in large repos (c.f. #189). FWIW I did a quick check with the full cpython source and on my machine the time is comparable to the existing commands,