diff --git a/lib/dialogs/cherrypick-dialog.coffee b/lib/dialogs/cherrypick-dialog.coffee new file mode 100644 index 0000000..28c95e4 --- /dev/null +++ b/lib/dialogs/cherrypick-dialog.coffee @@ -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 diff --git a/lib/git-control-view.coffee b/lib/git-control-view.coffee index 8519444..49d02f1 100644 --- a/lib/git-control-view.coffee +++ b/lib/git-control-view.coffee @@ -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() @@ -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', => @@ -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 diff --git a/lib/git.coffee b/lib/git.coffee index fc36703..c91a3df 100644 --- a/lib/git.coffee +++ b/lib/git.coffee @@ -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) -> diff --git a/lib/views/menu-view.coffee b/lib/views/menu-view.coffee index 01c9206..d11255d 100644 --- a/lib/views/menu-view.coffee +++ b/lib/views/menu-view.coffee @@ -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'} ] diff --git a/styles/icons.less b/styles/icons.less index 54a4ef1..aecae9f 100644 --- a/styles/icons.less +++ b/styles/icons.less @@ -143,5 +143,9 @@ &.x:before, &.file-deleted:before { content: '\f081' } + + &.git-pull-request:before { + content: '\f009' + } } }