Repository navigation
In the checkoutBranch method, move stash logic into new method. - #8087
Conversation
kuychaco
left a comment
There was a problem hiding this comment.
Looks good! ✨
Left one non-blocking suggestion to use const in favor of immutability
76bf2ee
outofambit
left a comment
There was a problem hiding this comment.
looks good great to me! thanks @probablycorey!
niik
left a comment
There was a problem hiding this comment.
Hey @probablycorey, thanks for working on cleanup up the _checkoutBranch method, it's definitely gotten unruly over time.
My first small request is that we let the enableStashing check live on as a guard to not show the popup when there are changes and to not call the stashBasedOnUncommittedChangesStrategy method. I know it seems kinda silly since the enableStashing method just returns true but I'd rather we keep all feature flag gates until we actually remove the flag. One can certainly make the argument that it's high time to remove the stashing feature flag (I'd support that) but we should do that in a separate PR IMO.
Secondly, while the refactor here is doing exactly what's promised in the PR body (i.e. it's a straightforward extraction refactor) I think we should look into having the stashBasedOnUncommittedChangesStrategy return the transientStashEntry if there is one rather than doing what we do now (have a temporary stash variable be either stashToPop or the transientStashEntry). It would make sense to me if this method would be responsible for returning whatever stash entry needs to be popped after switching branches and if that resonates with you it should probably handle the transient stash entry as well.
Lastly, while we don't require documentation for private methods I feel like this one warrants it, in particular in regards to the return value. Looking at stashBasedOnUncommittedChangesStrategy on its own we've lost the meaning of the return value (which previously was understood thanks to assigning it to the stashToPop variable). Either that or we take another pass at naming this method in a way that makes it clear, perhaps something like getOrCreateStashToPopAfterSwitchingBranches (yuck).
I'm less worried about the organic decay of feature-flag methods, but I'm deferring to your knowledge on this one!
This was annoying me too. I switched it around to do what you suggested.
I couldn't come up with a great new method name, so I updated the name to |
niik
left a comment
There was a problem hiding this comment.
Great stuff @probablycorey, thanks for taking the extra time to address my feedback.
I'm less worried about the organic decay of feature-flag methods, but I'm deferring to your knowledge on this one!
Yeah, in this case it's mostly a philosophical argument given that we don't anticipate ever turning stashing off using the feature flag but I still like keeping the removal of feature flags separate from new development.
This was annoying me too. I switched it around to do what you suggested. transientStashEntry was confusing to me, so hiding it behind a cleaner stash interface makes sense to me.
Yeah tell me about it, I had to spend some time reading code to remember what the heck that thing was doing.
I couldn't come up with a great new method name, so I updated the name to stashToPopAfterBranchCheckout and added a comment.
It's the best of the worst. Thanks so much!

Overview
Closes #7609
Description
This is a straight forward extraction of some code in the _checkoutBranch method .
_stashBasedOnUncommittedChangesStrategyso if you have a better name I'm all ears 🌽!enableStashingbecause the feature is globally enabled!