Skip to content

In the checkoutBranch method, move stash logic into new method. - #8087

Merged
niik merged 9 commits into
developmentfrom
chore/extract-stash-out-of-checkoutBranch
Aug 16, 2019
Merged

niik merged 9 commits into
developmentfrom
chore/extract-stash-out-of-checkoutBranch

Conversation

@probablycorey

@probablycorey probablycorey commented Aug 9, 2019 •

Copy link
Copy Markdown
Contributor

Overview

Closes #7609

Description

This is a straight forward extraction of some code in the _checkoutBranch method .

  • I ended up with a method name that is pretty long _stashBasedOnUncommittedChangesStrategy so if you have a better name I'm all ears 🌽!
  • I removed the enableStashing because the feature is globally enabled!

@probablycorey
probablycorey marked this pull request as ready for review August 9, 2019 18:06
@probablycorey probablycorey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 9, 2019
kuychaco
kuychaco previously approved these changes Aug 9, 2019

@kuychaco kuychaco left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! ✨

Left one non-blocking suggestion to use const in favor of immutability

Comment thread app/src/lib/stores/app-store.ts Resolved
Comment thread app/src/lib/stores/app-store.ts Resolved
outofambit
outofambit previously approved these changes Aug 9, 2019

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay! so glad this is happening! (had two little non-blocking nits)

dancing ghost nerd

Comment thread app/src/lib/stores/app-store.ts Resolved
Comment thread app/src/lib/stores/app-store.ts Resolved
@probablycorey
probablycorey dismissed stale reviews from outofambit and kuychaco via 76bf2ee August 12, 2019 17:50
outofambit
outofambit previously approved these changes Aug 12, 2019

@outofambit outofambit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good great to me! thanks @probablycorey!

@desktop desktop deleted a comment Aug 13, 2019

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@probablycorey

Copy link
Copy Markdown
Contributor Author

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...

I'm less worried about the organic decay of feature-flag methods, but I'm deferring to your knowledge on this one!

I think we should look into having the stashBasedOnUncommittedChangesStrategy return the transientStashEntry if there is one

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.

Lastly, while we don't require documentation for private methods I feel like this one warrants it,

I couldn't come up with a great new method name, so I updated the name to stashToPopAfterBranchCheckout and added a comment.

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@kuychaco kuychaco assigned niik and unassigned kuychaco Aug 16, 2019
@niik
niik merged commit 5b9edf1 into development Aug 16, 2019
@niik
niik deleted the chore/extract-stash-out-of-checkoutBranch branch August 16, 2019 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract stash creation in AppStore._checkoutBranch into its own method

4 participants