Repository navigation
Closed
Labels
epic:stashingTracking label for work related to the stashing flowtech-debtIssues and pull requests related to addressing technical debt or improving the codebase
Description
This is a follow up refactor issue (and a subset of the work captured in #7607) to simplify some logic in AppStore._checkoutBranch and localize variable creation and assignment for
desktop/app/src/lib/stores/app-store.ts
Line 2868 in 49d5d54
| let stashToPop: IStashEntry | null = null |
The idea is to encapsulate the following code block into its own private function on AppStore that returns Promise<StashEntry | null> so we can assign that result directly to stashToPop.
desktop/app/src/lib/stores/app-store.ts
Lines 2885 to 2916 in 49d5d54
| const { tip } = branchesState | |
| const currentBranch = tip.kind === TipState.Valid ? tip.branch : null | |
| if ( | |
| currentBranch !== null && | |
| uncommittedChangesStrategy.kind === | |
| UncommittedChangesStrategyKind.stashOnCurrentBranch | |
| ) { | |
| await this._createStashAndDropPreviousEntry( | |
| repository, | |
| currentBranch.name | |
| ) | |
| } else if ( | |
| uncommittedChangesStrategy.kind === | |
| UncommittedChangesStrategyKind.moveToNewBranch | |
| ) { | |
| const hasDeletedFiles = changesState.workingDirectory.files.some( | |
| file => file.status.kind === AppFileStatusKind.Deleted | |
| ) | |
| if (hasDeletedFiles) { | |
| const stashCreated = await gitStore.performFailableOperation(() => { | |
| return createDesktopStashEntry(repository, foundBranch.name) | |
| }) | |
| if (stashCreated) { | |
| stashToPop = await getLastDesktopStashEntryForBranch( | |
| repository, | |
| foundBranch.name | |
| ) | |
| } | |
| } | |
| } | |
| } |
And then check the stashToPop later in _checkoutBranch to see if we have something non-null to pop.
Originally posted by @outofambit in #7474
Metadata
Metadata
Assignees
Labels
epic:stashingTracking label for work related to the stashing flowtech-debtIssues and pull requests related to addressing technical debt or improving the codebase
Activity