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: use git stashes for gitWorkflow #663
Conversation
c873e14
to
1382586
Compare
Codecov Report
@@ Coverage Diff @@
## master #663 +/- ##
========================================
+ Coverage 99.67% 100% +0.32%
========================================
Files 11 11
Lines 306 278 -28
Branches 57 53 -4
========================================
- Hits 305 278 -27
+ Misses 1 0 -1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## beta #663 +/- ##
==========================================
- Coverage 99.67% 99.13% -0.55%
==========================================
Files 11 12 +1
Lines 309 347 +38
Branches 64 64
==========================================
+ Hits 308 344 +36
- Misses 1 3 +2
Continue to review full report at Codecov.
|
4b04d15
to
dfb013a
Compare
Regarding the TODO, it seems this branch doesn't pass the new test introduced in #664, so there's still something to be done about that. EDIT: this was solved by retrying with a 3-way merge |
66d1b21
to
61b2c03
Compare
@okonet Do you have thoughts on this? |
Didn’t have time to lock yet. Vacation :) |
Been craving a solution like this for a long time, good work @iiroj 🙂 |
I’m wondering where all the tests for the git stash are gone. They look deleted in the branch. |
@okonet If you mean tests for the partial staging logic, they have been removed as that is no longer done, but rather stashing is done every time. Since the workflow is different, the old tests no longer apply. |
Yes, but old tests could be modified since they test merging behavior. Right now there is no test asserting that the merge succeed and the right state being committed. |
And why is the logic would not apply? It’s still the multi step process so simulating it should give you similar results for git status. What am I missing? |
Alright, so the tests for calling of the separate methods have been removed, because they tested only the old logic. The full integration tests are still there and remain the same, as they test commits and git status. I guess I could rewrite those tests, but they do not increase coverage because Looking at
So there could still be tests for 3 and 4, since they are conditional. Additionally, if there are errors during 4, we should probably revert to the original status and fail committing, because in that case there's something messed up between staged and unstaged changes, caused by the tasks, and manual review would be the best. This is not currently the behaviour in the branch, since 3-way merging seems to handle them. |
I rebased this branch on top of |
with 4 that’s not really how it suppose to work since you almost always going to get conflicts with stash and reformatted files. The original version would apply as many changes as possible and ignore the conflicted hunks. I guess your version will just bail out. That said, this behavior also causes #565 since it ignores all errors which it shouldn’t probably so we can improve that. |
Are you open to considering this as a change in the way lint-staged should work (regarding bailing in case of unresolvable merge)? Currently, lint-staged is approaching being unusable in our large repo because of performance issues with it clearing the git index cache while running. This makes git actions take over a minute, and lint-staged itself like two minutes. I'm also open to trying different approaches to solve this issue. I think it might be possible to create a diff and apply in the same way as currently (linter modifications over the original state), but it would take multiple stashes. |
Git diff completely ignores new, untracked files, but they can be read/written separately
@iiroj I have to force push in order to change the branch. Please be aware and do |
Ah seems I misunderstood the idea. We have to merge to |
Ah fuck I screwed it didn't I? |
🎉 This PR is included in version 9.5.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@iiroj apparently it works as expected now I should have not rebased from Another thing I noticed, it won't release as |
@okonet I’ll add a breaking change to the commit when I update the readme about |
@iiroj what should we do about this branch? Should we try restoring it somehow? |
Ah I see, branch is in place the the PR is closed. We won't be able to re-open it I guess so you'd have to create a new one and refer to this one for the discussion. Okay? |
Alternatively we could rebase the branch back on master and see if that would help... Do you want me to try? |
@okonet nah it’s ok, I’ll open a new PR for the beta branch. |
This PR rewrites the
gitWorkflow
to use git stashes instead of cache-bustingread-tree
andwrite-tree
.Some benefits:
This currently passes all current tests (albeit with some modifications since the logic is a bit different), but I'm not sure about situations where there would be merge conflicts between modified and staged, and unstaged changes.
Consider this an evolution of #633, which did not pass all intergration scenarios.
TODO
Fixes
lint-staged
doesn't restore unstaged changed when it fails #550git commit
fails, ultimately causing lost work #565