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

Add cherry-pick feature #261

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions lib/dialogs/cherrypick-dialog.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Dialog = require './dialog'

git = require '../git'

module.exports =
class CherrypickDialog extends Dialog
@content: ->
@div class: 'dialog', =>
@div class: 'heading', =>
@i class: 'icon x clickable', click: 'cancel'
@strong 'Cherry-Pick'
@div class: 'body', =>
@label 'Current Branch'
@input class: 'native-key-bindings', type: 'text', readonly: true, outlet: 'toBranch'
@label 'Cherry-Pick From Commit'
@input class: 'native-key-bindings', type: 'text', outlet: 'fromCommit'
@div class: 'buttons', =>
@button class: 'active', click: 'cherrypick', =>
@i class: 'icon check'
@span 'Cherry-Pick'
@button click: 'cancel', =>
@i class: 'icon x'
@span 'Cancel'

activate: (branches) ->
current = git.getLocalBranch()

@toBranch.val(current)
@fromCommit.find('option').remove()

return super()

cherrypick: ->
@deactivate()
@parentView.cherrypick(@fromCommit.val())
return
10 changes: 10 additions & 0 deletions lib/git-control-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ PushDialog = require './dialogs/push-dialog'
PushTagsDialog = require './dialogs/push-tags-dialog'
RebaseDialog = require './dialogs/rebase-dialog'
MidrebaseDialog = require './dialogs/midrebase-dialog'
CherrypickDialog = require './dialogs/cherrypick-dialog'

runShell = (cmd, output) ->
shell = child_process.execSync(cmd, { encoding: 'utf8'}).trim()
Expand Down Expand Up @@ -55,6 +56,7 @@ class GitControlView extends View
@subview 'pushtagDialog', new PushTagsDialog()
@subview 'rebaseDialog', new RebaseDialog()
@subview 'midrebaseDialog', new MidrebaseDialog()
@subview 'cherrypickDialog', new CherrypickDialog()
@subview 'logView', new LogView()
else #This is so that no error messages can be created by pushing buttons that are unavailable.
@div class: 'git-control', =>
Expand Down Expand Up @@ -151,6 +153,14 @@ class GitControlView extends View
@branchDialog.activate()
return

cherrypickMenuClick: ->
@cherrypickDialog.activate(@branches.local)
return

cherrypick: (commit) =>
git.cherrypick(commit).then => @update()
return

compareMenuClick: ->
git.diff(@filesView.getSelected().all.join(' ')).then (diffs) => @diffView.addAll(diffs)
return
Expand Down
5 changes: 5 additions & 0 deletions lib/git.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ module.exports =
atomRefresh()
return parseDefault(data)

cherrypick: (commit) ->
return callGit "cherry-pick #{commit}", (data) ->
atomRefresh()
return parseDefault(data)

createBranch: (branch) ->
return callGit "branch #{branch}", (data) ->
return callGit "checkout #{branch}", (data) ->
Expand Down
1 change: 1 addition & 0 deletions lib/views/menu-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ items = [
{ id: 'push', menu: 'Push', icon: 'push', type: 'downstream'}
{ id: 'rebase', menu: 'Rebase', icon: 'circuit-board', type: 'active'}
{ id: 'merge', menu: 'Merge', icon: 'merge', type: 'active'}
{ id: 'cherrypick', menu: 'Cherry-Pick', icon: 'git-pull-request', type: 'active'}
{ id: 'branch', menu: 'Branch', icon: 'branch', type: 'active'}
{ id: 'flow', menu: 'GitFlow', icon: 'flow', type: 'active', showConfig: 'git-control.showGitFlowButton'}
]
Expand Down
4 changes: 4 additions & 0 deletions styles/icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,9 @@
&.x:before, &.file-deleted:before {
content: '\f081'
}

&.git-pull-request:before {
content: '\f009'
}
}
}