Skip to content

Commit

Permalink
Remove stashing before switching into a branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
mykolaharmash committed Oct 15, 2020
1 parent b6c5f83 commit 06ef3d7
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,29 +932,6 @@ function gitSwitch(args: string[]): GitCommandResult {
return switchResult
}

function switchBranch(branchName: string, state: State): { status: number, message: string[] } {
const statusResult = gitCommand('status', ['--porcelain'])
const statusDirty = statusResult.stdout.length > 0

if (!statusDirty) {
return gitSwitch([branchName])
}

const results = chainGitCommands(
() => gitCommand('stash', ['--include-untracked']),
() => gitSwitch([branchName]),
() => gitCommand('stash', ['apply'])
)

const compoundResult = compoundGitCommandsResult(results)
compoundResult.message = [
`There are uncommitted changes. Will stash them and apply to ${bold(branchName)} after switch.`,
''
].concat(compoundResult.message)

return compoundResult
}

function switchToListItem(item: ListItem): void {
const branchName = getBranchNameForLine(item)

Expand All @@ -966,7 +943,7 @@ function switchToListItem(item: ListItem): void {
process.exit(0)
}

const { status, message } = switchBranch(branchName, state)
const { status, message } = gitSwitch([branchName])

state.scene = Scene.Message
state.message = message
Expand Down

0 comments on commit 06ef3d7

Please sign in to comment.