Skip to content

Add all foundation stash functions needed to support stashing in the app - #7182

Merged
shiftkey merged 38 commits into
developmentfrom
all-stash-functions
Apr 4, 2019
Merged

shiftkey merged 38 commits into
developmentfrom
all-stash-functions

Conversation

@iAmWillShepherd

Copy link
Copy Markdown
Contributor

See tracking issue for more details - #6987

This PR brings together the functionality from the following PRs:

These functions are needed to support the following workflows:

  • Stashing changes on current branch
  • Bringing changes over to new branch

How do these functions relate to one another?

Both workflows start off from the same stash dialog.

Stashing changes on current branch

  1. If there is an entry associated with the branch, drop it - getLastDesktopStashEntryForBranch -> dropDesktopStashEntry
  2. Create stash entry for the current branch - createDesktopStashEntry
  3. Perform the checkout
  4. Check to see if new branch has an existing stash entry - getLastDesktopStashEntryForBranch

Move to new branch and take changes there

  1. If there is an entry associated with the new branch, update the UI to inform user stash on new branch would be overwritten - getLastDesktopStashEntryForBranch -> dropDesktopStashEntry
  2. Create stash entry for the new branch - createDesktopStashEntry
  3. Perform the checkout
  4. Apply the newly created stash immediately - applyStashEntry
  5. Drop stash entry once applied - dropDesktopStashEntry

@shiftkey shiftkey 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 to see all of these related APIs aggregated together so we can talk about them as a set! 🎉

Some initial questions, mostly about how much defensiveness should be baked into the Git plumbing...

Comment thread app/test/unit/git/stash-test.ts Resolved
Comment thread app/src/lib/git/stash.ts Resolved
Comment thread app/src/lib/git/stash.ts Resolved
Comment thread app/src/lib/git/stash.ts Resolved
William Shepherd and others added 12 commits April 1, 2019 09:31
Using the create and store commands don't automatically clear the working tree. Since doing that just for testing is a bit much, I decided to just use what works and move on.
This is needed because `git stash drop stash@{<commit SHA>}` doesn't always work.
Using the `toHaveLength` function was failing even though the returned object `  [{"branchName": "master", "name": "stash@{0}", "stashSha": "6a722cb052d4827a3ba1c21a15e6ec16409d4545"}]` only has one item.
Comment thread app/src/lib/git/stash.ts Resolved
Comment thread app/src/lib/git/stash.ts Resolved
William Shepherd and others added 6 commits April 2, 2019 11:07
It seems using the same content in the file was causing one stash entry to get created dusring test execution. This is likely due to changes to files not being written to disk at the right time.

Co-Authored-By: Brendan Forster <[email protected]>
Updated to remain consistent with coding style
Comment thread app/test/unit/git/stash-test.ts Resolved
@iAmWillShepherd iAmWillShepherd added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 2, 2019

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

LGTM

@shiftkey

shiftkey commented Apr 3, 2019

Copy link
Copy Markdown
Member

I plan to merge this in tomorrow morning unless others have feedback to add

@shiftkey
shiftkey merged commit 817d9bf into development Apr 4, 2019
@iAmWillShepherd
iAmWillShepherd deleted the all-stash-functions branch April 5, 2019 15:22
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.

2 participants