diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-21 20:40:20 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-23 14:29:18 +1000 |
commit | 1fd0f31682a1b55f22508309e6a16a3e56ac0206 (patch) | |
tree | 45e05092c0d91d40708256d300fa1e5e07ab1c68 /pkg | |
parent | e6a1bd656620d2b786266b593b197721d669085a (diff) |
only show rebasey commands on a local commit when patch building
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/patch_building_panel.go | 10 | ||||
-rw-r--r-- | pkg/gui/patch_options_panel.go | 29 |
2 files changed, 29 insertions, 10 deletions
diff --git a/pkg/gui/patch_building_panel.go b/pkg/gui/patch_building_panel.go index c39568cdf..6e2bcf8af 100644 --- a/pkg/gui/patch_building_panel.go +++ b/pkg/gui/patch_building_panel.go @@ -1,6 +1,8 @@ package gui import ( + "strings" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -119,3 +121,11 @@ func (gui *Gui) secondaryPatchPanelUpdateOpts() *viewUpdateOpts { return nil } + +func (gui *Gui) handleCopyPatchToClipboard() error { + // TODO: test that this works + + return gui.OSCommand.CopyToClipboard( + strings.Join(gui.GitCommand.PatchManager.RenderEachFilePatch(true), "\n"), + ) +} diff --git a/pkg/gui/patch_options_panel.go b/pkg/gui/patch_options_panel.go index 844ecbd36..2b6ec0c2a 100644 --- a/pkg/gui/patch_options_panel.go +++ b/pkg/gui/patch_options_panel.go @@ -13,16 +13,8 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error menuItems := []*menuItem{ { - displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.Parent), - onPress: gui.handleDeletePatchFromCommit, - }, - { - displayString: "pull patch out into index", - onPress: gui.handlePullPatchIntoWorkingTree, - }, - { - displayString: "pull patch into new commit", - onPress: gui.handlePullPatchIntoNewCommit, + displayString: "copy patch", + onPress: gui.handleCopyPatchToClipboard, }, { displayString: "apply patch", @@ -38,6 +30,23 @@ func (gui *Gui) handleCreatePatchOptionsMenu(g *gocui.Gui, v *gocui.View) error }, } + if gui.GitCommand.PatchManager.CanRebase { + menuItems = append(menuItems, []*menuItem{ + { + displayString: fmt.Sprintf("remove patch from original commit (%s)", gui.GitCommand.PatchManager.Parent), + onPress: gui.handleDeletePatchFromCommit, + }, + { + displayString: "pull patch out into index", + onPress: gui.handlePullPatchIntoWorkingTree, + }, + { + displayString: "pull patch into new commit", + onPress: gui.handlePullPatchIntoNewCommit, + }, + }...) + } + selectedCommit := gui.getSelectedCommit() if selectedCommit != nil && gui.GitCommand.PatchManager.Parent != selectedCommit.Sha { // adding this option to index 1 |