Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Added simple stash support
Browse files Browse the repository at this point in the history
  • Loading branch information
ziacik committed Apr 22, 2016
1 parent 3a1405f commit a456501
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/git-control-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ class GitControlView extends View
git.pullup().then => @update(true)
return

stashSaveMenuClick: ->
git.stashSave().then => @update(true)
return

stashPopMenuClick: ->
git.stashPop().then => @update(true)
return

pushMenuClick: ->
git.getBranches().then (branches) => @pushDialog.activate(branches.remote)
return
Expand Down
12 changes: 11 additions & 1 deletion lib/git.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ callGit = (cmd, parser, nodatalog) ->
logcb e.stdout, true
logcb e.message, true
return

module.exports =
isInitialised: ->
return cwd
Expand Down Expand Up @@ -223,5 +223,15 @@ module.exports =
atomRefresh()
return parseDefault(true)

stashSave: ->
return callGit "stash save", (data) ->
atomRefresh()
return parseDefault(data)

stashPop: ->
return callGit "stash pop", (data) ->
atomRefresh()
return parseDefault(data)

status: ->
return callGit 'status --porcelain --untracked-files=all', parseStatus
2 changes: 2 additions & 0 deletions lib/views/menu-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ items = [
{ id: 'push', menu: 'Push', icon: 'push', type: 'downstream'}
{ id: 'merge', menu: 'Merge', icon: 'merge', type: 'active'}
{ id: 'branch', menu: 'Branch', icon: 'branch', type: 'active'}
{ id: 'stashSave', menu: 'Stash Save', icon: 'stash-save', type: 'file merging'}
{ id: 'stashPop', menu: 'Stash Pop', icon: 'stash-pop', type: 'active'}
#{ id: 'tag', menu: 'Tag', icon: 'tag'}
{ id: 'flow', menu: 'GitFlow', icon: 'flow', type: 'active', showConfig: 'git-control.showGitFlowButton'}
]
Expand Down
24 changes: 22 additions & 2 deletions spec/git-control-view-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
git = require '../lib/git'
GitControlView = require '../lib/git-control-view'

describe "GitControlView", ->
it "has one valid test", ->
expect("life").toBe "easy"
updateSpy = null
stashSaveSpy = null
stashPopSpy = null
gitControlView = null

beforeEach ->
gitControlView = new GitControlView()
updateSpy = spyOn(gitControlView, 'update')
fakePromise = then : (f) -> f()
stashSaveSpy = spyOn(git, 'stashSave').andReturn(fakePromise)
stashPopSpy = spyOn(git, 'stashPop').andReturn(fakePromise)

it "calls git stashSave on Stash Save", ->
gitControlView.stashSaveMenuClick()
expect(stashSaveSpy).toHaveBeenCalled()
expect(updateSpy).toHaveBeenCalled()

it "calls git stashPop on Stash Pop", ->
gitControlView.stashPopMenuClick()
expect(stashPopSpy).toHaveBeenCalled()
expect(updateSpy).toHaveBeenCalled()
8 changes: 8 additions & 0 deletions styles/icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@
content: '\f053'
}

&.stash-save:before {
content: '\f036'
}

&.stash-pop:before {
content: '\f032'
}

&.sync:before {
content: '\f087'
}
Expand Down

0 comments on commit a456501

Please sign in to comment.