Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Autostash option #707

Merged
merged 2 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,20 @@ module.exports =
type: "boolean"
default: false
description: "Pull with `--rebase` flag?"
pullBeforePush:
pullAutostash:
order: 2
title: "Pull AutoStash"
type: "boolean"
default: false
description: "Pull with `--autostash` flag?"
pullBeforePush:
order: 3
title: "Pull Before Pushing"
type: "boolean"
default: false
description: "Pull from remote before pushing"
promptForBranch:
order: 3
order: 4
title: "Prompt for branch selection when pulling/pushing"
type: "boolean"
default: false
Expand Down
2 changes: 2 additions & 0 deletions lib/models/git-pull.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ RemoteListView = require '../views/remote-list-view'

module.exports = (repo) ->
extraArgs = if atom.config.get('git-plus.remoteInteractions.pullRebase') then ['--rebase'] else []
if atom.config.get('git-plus.remoteInteractions.pullAutostash')
extraArgs.push '--autostash'
if atom.config.get('git-plus.remoteInteractions.promptForBranch')
git.cmd(['remote'], cwd: repo.getWorkingDirectory())
.then (data) ->
Expand Down
19 changes: 19 additions & 0 deletions spec/models/git-pull-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ describe "Git Pull", ->
GitPull(repo)
expect(git.cmd).toHaveBeenCalledWith ['remote'], options

describe "when 'pullRebase' is enabled", ->
it 'calls git.cmd with --rebase', ->
atom.config.set('git-plus.remoteInteractions.pullRebase', true)
GitPull(repo)
expect(git.cmd).toHaveBeenCalledWith ['pull', '--rebase', 'origin', 'foo'], options, {color:true}

describe "when 'pullAutostash' is enabled", ->
it 'calls git.cmd with --autostash', ->
atom.config.set('git-plus.remoteInteractions.pullAutostash', true)
GitPull(repo)
expect(git.cmd).toHaveBeenCalledWith ['pull', '--autostash', 'origin', 'foo'], options, {color:true}

describe "when 'pullRebase' and 'pullAutostash' are enabled", ->
it 'calls git.cmd with --rebase and --autostash', ->
atom.config.set('git-plus.remoteInteractions.pullRebase', true)
atom.config.set('git-plus.remoteInteractions.pullAutostash', true)
GitPull(repo)
expect(git.cmd).toHaveBeenCalledWith ['pull', '--rebase', '--autostash', 'origin', 'foo'], options, {color:true}

describe "The pull function", ->
it "calls git.cmd", ->
_pull repo
Expand Down