2018-08-14 11:05:26 +02:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import (
|
2021-04-10 09:31:23 +02:00
|
|
|
"fmt"
|
2020-03-26 14:48:11 +02:00
|
|
|
"sync"
|
2018-08-14 11:05:26 +02:00
|
|
|
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
2020-09-29 12:28:39 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
2021-04-10 09:31:23 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
2020-10-04 02:00:48 +02:00
|
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
2018-08-14 11:05:26 +02:00
|
|
|
)
|
|
|
|
|
2018-12-06 13:18:17 +02:00
|
|
|
// list panel functions
|
|
|
|
|
2020-09-29 10:36:54 +02:00
|
|
|
func (gui *Gui) getSelectedLocalCommit() *models.Commit {
|
2020-08-20 00:53:10 +02:00
|
|
|
selectedLine := gui.State.Panels.Commits.SelectedLineIdx
|
2021-04-03 02:32:14 +02:00
|
|
|
if selectedLine == -1 || selectedLine > len(gui.State.Commits)-1 {
|
2018-12-06 13:18:17 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return gui.State.Commits[selectedLine]
|
|
|
|
}
|
|
|
|
|
2020-08-15 09:01:43 +02:00
|
|
|
func (gui *Gui) handleCommitSelect() error {
|
2020-01-11 09:23:35 +02:00
|
|
|
state := gui.State.Panels.Commits
|
2020-08-20 00:53:10 +02:00
|
|
|
if state.SelectedLineIdx > 290 && state.LimitCommits {
|
2020-01-11 09:23:35 +02:00
|
|
|
state.LimitCommits = false
|
2020-10-07 12:19:38 +02:00
|
|
|
go utils.Safe(func() {
|
2020-01-11 09:23:35 +02:00
|
|
|
if err := gui.refreshCommitsWithLimit(); err != nil {
|
2020-03-28 02:47:54 +02:00
|
|
|
_ = gui.surfaceError(err)
|
2020-01-11 09:23:35 +02:00
|
|
|
}
|
2020-10-07 12:19:38 +02:00
|
|
|
})
|
2020-01-11 09:23:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 23:56:14 +02:00
|
|
|
gui.escapeLineByLinePanel()
|
2019-11-10 07:20:35 +02:00
|
|
|
|
2020-08-18 14:02:35 +02:00
|
|
|
var task updateTask
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2018-12-06 13:18:17 +02:00
|
|
|
if commit == nil {
|
2021-04-04 15:51:59 +02:00
|
|
|
task = NewRenderStringTask(gui.Tr.NoCommitsThisBranch)
|
2020-08-18 14:02:35 +02:00
|
|
|
} else {
|
|
|
|
cmd := gui.OSCommand.ExecutableFromString(
|
2021-04-03 02:32:14 +02:00
|
|
|
gui.GitCommand.ShowCmdStr(commit.Sha, gui.State.Modes.Filtering.GetPath()),
|
2020-08-18 14:02:35 +02:00
|
|
|
)
|
2021-04-04 15:51:59 +02:00
|
|
|
task = NewRunPtyTask(cmd)
|
2018-12-06 13:18:17 +02:00
|
|
|
}
|
allow fast flicking through any list panel
Up till now our approach to rendering things like file diffs, branch logs, and
commit patches, has been to run a command on the command line, wait for it to
complete, take its output as a string, and then write that string to the main
view (or secondary view e.g. when showing both staged and unstaged changes of a
file).
This has caused various issues. For once, if you are flicking through a list of
files and an untracked file is particularly large, not only will this require
lazygit to load that whole file into memory (or more accurately it's equally
large diff), it also will slow down the UI thread while loading that file, and
if the user continued down the list, the original command might eventually
resolve and replace whatever the diff is for the newly selected file.
Following what we've done in lazydocker, I've added a tasks package for when you
need something done but you want it to cancel as soon as something newer comes
up. Given this typically involves running a command to display to a view, I've
added a viewBufferManagerMap struct to the Gui struct which allows you to define
these tasks on a per-view basis.
viewBufferManagers can run files and directly write the output to their view,
meaning we no longer need to use so much memory.
In the tasks package there is a helper method called NewCmdTask which takes a
command, an initial amount of lines to read, and then runs that command, reads
that number of lines, and allows for a readLines channel to tell it to read more
lines. We read more lines when we scroll or resize the window.
There is an adapter for the tasks package in a file called tasks_adapter which
wraps the functions from the tasks package in gui-specific stuff like clearing
the main view before starting the next task that wants to write to the main
view.
I've removed some small features as part of this work, namely the little headers
that were at the top of the main view for some situations. For example, we no
longer show the upstream of a selected branch. I want to re-introduce this in
the future, but I didn't want to make this tasks system too complicated, and in
order to facilitate a header section in the main view we'd need to have a task
that gets the upstream for the current branch, writes it to the header, then
tells another task to write the branch log to the main view, but without
clearing inbetween. So it would get messy. I'm thinking instead of having a
separate 'header' view atop the main view to render that kind of thing (which
can happen in another PR)
I've also simplified the 'git show' to just call 'git show' and not do anything
fancy when it comes to merge commits.
I considered using this tasks approach whenever we write to a view. The only
thing is that the renderString method currently resets the origin of a view and
I don't want to lose that. So I've left some in there that I consider harmless,
but we should probably be just using tasks now for all rendering, even if it's
just strings we can instantly make.
2020-01-11 05:54:59 +02:00
|
|
|
|
2020-08-23 01:46:28 +02:00
|
|
|
return gui.refreshMainViews(refreshMainOpts{
|
2020-08-18 14:02:35 +02:00
|
|
|
main: &viewUpdateOpts{
|
|
|
|
title: "Patch",
|
|
|
|
task: task,
|
|
|
|
},
|
|
|
|
secondary: gui.secondaryPatchPanelUpdateOpts(),
|
|
|
|
})
|
2018-12-06 13:18:17 +02:00
|
|
|
}
|
|
|
|
|
2020-03-28 02:22:11 +02:00
|
|
|
// during startup, the bottleneck is fetching the reflog entries. We need these
|
|
|
|
// on startup to sort the branches by recency. So we have two phases: INITIAL, and COMPLETE.
|
2020-03-28 02:27:05 +02:00
|
|
|
// In the initial phase we don't get any reflog commits, but we asynchronously get them
|
|
|
|
// and refresh the branches after that
|
2020-03-28 02:22:11 +02:00
|
|
|
func (gui *Gui) refreshReflogCommitsConsideringStartup() {
|
|
|
|
switch gui.State.StartupStage {
|
|
|
|
case INITIAL:
|
2020-10-07 12:19:38 +02:00
|
|
|
go utils.Safe(func() {
|
2020-03-28 02:47:54 +02:00
|
|
|
_ = gui.refreshReflogCommits()
|
2020-03-28 02:22:11 +02:00
|
|
|
gui.refreshBranches()
|
|
|
|
gui.State.StartupStage = COMPLETE
|
2020-10-07 12:19:38 +02:00
|
|
|
})
|
2020-03-28 02:22:11 +02:00
|
|
|
|
|
|
|
case COMPLETE:
|
2020-03-28 02:47:54 +02:00
|
|
|
_ = gui.refreshReflogCommits()
|
2020-03-28 02:22:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-28 01:27:34 +02:00
|
|
|
// whenever we change commits, we should update branches because the upstream/downstream
|
|
|
|
// counts can change. Whenever we change branches we should probably also change commits
|
2020-03-28 02:22:11 +02:00
|
|
|
// e.g. in the case of switching branches.
|
2020-03-27 12:23:42 +02:00
|
|
|
func (gui *Gui) refreshCommits() error {
|
2020-03-26 14:48:11 +02:00
|
|
|
wg := sync.WaitGroup{}
|
|
|
|
wg.Add(2)
|
2018-09-17 13:02:30 +02:00
|
|
|
|
2020-10-07 12:19:38 +02:00
|
|
|
go utils.Safe(func() {
|
2020-03-28 02:22:11 +02:00
|
|
|
gui.refreshReflogCommitsConsideringStartup()
|
|
|
|
|
2020-03-26 14:48:11 +02:00
|
|
|
gui.refreshBranches()
|
|
|
|
wg.Done()
|
2020-10-07 12:19:38 +02:00
|
|
|
})
|
2020-03-26 14:48:11 +02:00
|
|
|
|
2020-10-07 12:19:38 +02:00
|
|
|
go utils.Safe(func() {
|
2020-03-28 02:47:54 +02:00
|
|
|
_ = gui.refreshCommitsWithLimit()
|
2021-04-03 06:56:11 +02:00
|
|
|
context, ok := gui.State.Contexts.CommitFiles.GetParentContext()
|
2020-09-26 03:35:06 +02:00
|
|
|
if ok && context.GetKey() == BRANCH_COMMITS_CONTEXT_KEY {
|
|
|
|
// This makes sense when we've e.g. just amended a commit, meaning we get a new commit SHA at the same position.
|
|
|
|
// However if we've just added a brand new commit, it pushes the list down by one and so we would end up
|
|
|
|
// showing the contents of a different commit than the one we initially entered.
|
|
|
|
// Ideally we would know when to refresh the commit files context and when not to,
|
|
|
|
// or perhaps we could just pop that context off the stack whenever cycling windows.
|
|
|
|
// For now the awkwardness remains.
|
|
|
|
commit := gui.getSelectedLocalCommit()
|
|
|
|
if commit != nil {
|
|
|
|
gui.State.Panels.CommitFiles.refName = commit.RefName()
|
|
|
|
_ = gui.refreshCommitFilesView()
|
|
|
|
}
|
2020-03-27 10:12:15 +02:00
|
|
|
}
|
2020-03-26 14:48:11 +02:00
|
|
|
wg.Done()
|
2020-10-07 12:19:38 +02:00
|
|
|
})
|
2020-03-26 13:51:24 +02:00
|
|
|
|
2020-03-26 14:48:11 +02:00
|
|
|
wg.Wait()
|
2020-03-26 14:20:12 +02:00
|
|
|
|
2018-08-14 11:05:26 +02:00
|
|
|
return nil
|
2020-01-11 09:23:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) refreshCommitsWithLimit() error {
|
2020-10-07 12:45:57 +02:00
|
|
|
gui.Mutexes.BranchCommitsMutex.Lock()
|
|
|
|
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
2020-08-27 12:50:30 +02:00
|
|
|
|
|
|
|
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
|
2020-08-22 00:49:02 +02:00
|
|
|
|
|
|
|
commits, err := builder.GetCommits(
|
|
|
|
commands.GetCommitsOptions{
|
|
|
|
Limit: gui.State.Panels.Commits.LimitCommits,
|
2021-04-03 02:32:14 +02:00
|
|
|
FilterPath: gui.State.Modes.Filtering.GetPath(),
|
2020-08-22 00:49:02 +02:00
|
|
|
IncludeRebaseCommits: true,
|
|
|
|
RefName: "HEAD",
|
|
|
|
},
|
|
|
|
)
|
2020-01-11 09:23:35 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
gui.State.Commits = commits
|
|
|
|
|
2021-04-03 06:56:11 +02:00
|
|
|
return gui.postRefreshUpdate(gui.State.Contexts.BranchCommits)
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
|
|
|
|
2020-08-27 12:50:30 +02:00
|
|
|
func (gui *Gui) refreshRebaseCommits() error {
|
2020-10-07 12:45:57 +02:00
|
|
|
gui.Mutexes.BranchCommitsMutex.Lock()
|
|
|
|
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
2020-08-27 12:50:30 +02:00
|
|
|
|
|
|
|
builder := commands.NewCommitListBuilder(gui.Log, gui.GitCommand, gui.OSCommand, gui.Tr)
|
|
|
|
|
|
|
|
updatedCommits, err := builder.MergeRebasingCommits(gui.State.Commits)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
gui.State.Commits = updatedCommits
|
|
|
|
|
2021-04-03 06:56:11 +02:00
|
|
|
return gui.postRefreshUpdate(gui.State.Contexts.BranchCommits)
|
2020-08-27 12:50:30 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 13:18:17 +02:00
|
|
|
// specific functions
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitSquashDown() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-12-04 10:50:11 +02:00
|
|
|
if len(gui.State.Commits) <= 1 {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.createErrorPanel(gui.Tr.YouNoCommitsToSquash)
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
|
|
|
|
applied, err := gui.handleMidRebaseCommand("squash")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
if applied {
|
|
|
|
return nil
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.Squash,
|
|
|
|
prompt: gui.Tr.SureSquashThisCommit,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.SquashingStatus, func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
err := gui.GitCommand.WithSpan(gui.Tr.Spans.SquashCommitDown).InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "squash")
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitFixup() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-12-04 10:50:11 +02:00
|
|
|
if len(gui.State.Commits) <= 1 {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.createErrorPanel(gui.Tr.YouNoCommitsToSquash)
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
|
|
|
|
applied, err := gui.handleMidRebaseCommand("fixup")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
if applied {
|
|
|
|
return nil
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.Fixup,
|
|
|
|
prompt: gui.Tr.SureFixupThisCommit,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.FixingStatus, func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
err := gui.GitCommand.WithSpan(gui.Tr.Spans.FixupCommit).InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "fixup")
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleRenameCommit() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:36:29 +02:00
|
|
|
applied, err := gui.handleMidRebaseCommand("reword")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-20 00:53:10 +02:00
|
|
|
if gui.State.Panels.Commits.SelectedLineIdx != 0 {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.createErrorPanel(gui.Tr.OnlyRenameTopCommit)
|
2018-08-14 11:05:26 +02:00
|
|
|
}
|
2020-08-16 11:31:55 +02:00
|
|
|
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2020-08-16 11:31:55 +02:00
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
message, err := gui.GitCommand.GetCommitMessage(commit.Sha)
|
|
|
|
if err != nil {
|
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
|
|
|
|
2020-11-28 04:35:58 +02:00
|
|
|
return gui.prompt(promptOpts{
|
|
|
|
title: gui.Tr.LcRenameCommit,
|
|
|
|
initialContent: message,
|
|
|
|
handleConfirm: func(response string) error {
|
2021-04-11 11:35:42 +02:00
|
|
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.RewordCommit).RenameCommit(response); err != nil {
|
2020-11-28 04:35:58 +02:00
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
2020-03-27 12:25:37 +02:00
|
|
|
|
2020-11-28 04:35:58 +02:00
|
|
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
|
|
|
},
|
2018-08-14 11:05:26 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleRenameCommitEditor() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:36:29 +02:00
|
|
|
applied, err := gui.handleMidRebaseCommand("reword")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-11 11:35:42 +02:00
|
|
|
subProcess, err := gui.GitCommand.WithSpan(gui.Tr.Spans.RewordCommit).RewordCommit(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx)
|
2019-02-18 12:29:43 +02:00
|
|
|
if err != nil {
|
2020-03-28 02:47:54 +02:00
|
|
|
return gui.surfaceError(err)
|
2018-08-29 14:27:17 +02:00
|
|
|
}
|
2019-02-18 12:29:43 +02:00
|
|
|
if subProcess != nil {
|
2021-04-10 03:40:42 +02:00
|
|
|
return gui.runSubprocessWithSuspenseAndRefresh(subProcess)
|
2019-02-18 12:29:43 +02:00
|
|
|
}
|
2018-08-29 14:27:17 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2019-02-18 14:27:54 +02:00
|
|
|
|
2019-02-19 14:36:29 +02:00
|
|
|
// handleMidRebaseCommand sees if the selected commit is in fact a rebasing
|
|
|
|
// commit meaning you are trying to edit the todo file rather than actually
|
|
|
|
// begin a rebase. It then updates the todo file with that action
|
|
|
|
func (gui *Gui) handleMidRebaseCommand(action string) (bool, error) {
|
2020-08-20 00:53:10 +02:00
|
|
|
selectedCommit := gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx]
|
2019-02-24 00:42:24 +02:00
|
|
|
if selectedCommit.Status != "rebasing" {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
2019-02-20 13:52:17 +02:00
|
|
|
// for now we do not support setting 'reword' because it requires an editor
|
|
|
|
// and that means we either unconditionally wait around for the subprocess to ask for
|
|
|
|
// our input or we set a lazygit client as the EDITOR env variable and have it
|
|
|
|
// request us to edit the commit message when prompted.
|
|
|
|
if action == "reword" {
|
2020-10-04 02:00:48 +02:00
|
|
|
return true, gui.createErrorPanel(gui.Tr.LcRewordNotSupported)
|
2019-02-20 13:52:17 +02:00
|
|
|
}
|
|
|
|
|
2021-04-10 09:31:23 +02:00
|
|
|
gui.OnRunCommand(oscommands.NewCmdLogEntry(
|
|
|
|
fmt.Sprintf("Updating rebase action of commit %s to '%s'", selectedCommit.ShortSha(), action),
|
|
|
|
"Update rebase TODO",
|
|
|
|
false,
|
|
|
|
))
|
|
|
|
|
2020-08-20 00:53:10 +02:00
|
|
|
if err := gui.GitCommand.EditRebaseTodo(gui.State.Panels.Commits.SelectedLineIdx, action); err != nil {
|
2020-03-28 02:47:54 +02:00
|
|
|
return false, gui.surfaceError(err)
|
2019-02-19 14:36:29 +02:00
|
|
|
}
|
2020-08-27 12:50:30 +02:00
|
|
|
|
|
|
|
return true, gui.refreshRebaseCommits()
|
2019-02-19 14:36:29 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitDelete() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:36:29 +02:00
|
|
|
applied, err := gui.handleMidRebaseCommand("drop")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.DeleteCommitTitle,
|
|
|
|
prompt: gui.Tr.DeleteCommitPrompt,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.DeletingStatus, func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
err := gui.GitCommand.WithSpan(gui.Tr.Spans.DropCommit).InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "drop")
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
2019-02-18 14:27:54 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitMoveDown() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-04-11 11:35:42 +02:00
|
|
|
span := gui.Tr.Spans.MoveCommitDown
|
2021-04-10 09:31:23 +02:00
|
|
|
|
2020-08-20 00:53:10 +02:00
|
|
|
index := gui.State.Panels.Commits.SelectedLineIdx
|
2019-02-20 11:51:24 +02:00
|
|
|
selectedCommit := gui.State.Commits[index]
|
|
|
|
if selectedCommit.Status == "rebasing" {
|
|
|
|
if gui.State.Commits[index+1].Status != "rebasing" {
|
|
|
|
return nil
|
|
|
|
}
|
2021-04-10 09:31:23 +02:00
|
|
|
|
|
|
|
// logging directly here because MoveTodoDown doesn't have enough information
|
|
|
|
// to provide a useful log
|
|
|
|
gui.OnRunCommand(oscommands.NewCmdLogEntry(
|
|
|
|
fmt.Sprintf("Moving commit %s down", selectedCommit.ShortSha()),
|
|
|
|
span,
|
|
|
|
false,
|
|
|
|
))
|
|
|
|
|
2019-02-20 11:51:24 +02:00
|
|
|
if err := gui.GitCommand.MoveTodoDown(index); err != nil {
|
2020-03-28 02:47:54 +02:00
|
|
|
return gui.surfaceError(err)
|
2019-02-20 11:51:24 +02:00
|
|
|
}
|
2020-08-20 00:53:10 +02:00
|
|
|
gui.State.Panels.Commits.SelectedLineIdx++
|
2020-08-29 01:52:01 +02:00
|
|
|
return gui.refreshRebaseCommits()
|
2019-02-20 11:51:24 +02:00
|
|
|
}
|
2019-02-18 14:27:54 +02:00
|
|
|
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.MovingStatus, func() error {
|
2021-04-10 09:31:23 +02:00
|
|
|
err := gui.GitCommand.WithSpan(span).MoveCommitDown(gui.State.Commits, index)
|
2019-03-03 06:21:33 +02:00
|
|
|
if err == nil {
|
2020-08-20 00:53:10 +02:00
|
|
|
gui.State.Panels.Commits.SelectedLineIdx++
|
2019-03-03 06:21:33 +02:00
|
|
|
}
|
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
2019-02-18 14:27:54 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitMoveUp() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-08-20 00:53:10 +02:00
|
|
|
index := gui.State.Panels.Commits.SelectedLineIdx
|
2019-02-20 11:51:24 +02:00
|
|
|
if index == 0 {
|
|
|
|
return nil
|
2019-02-18 14:27:54 +02:00
|
|
|
}
|
2021-04-10 09:31:23 +02:00
|
|
|
|
2021-04-11 11:35:42 +02:00
|
|
|
span := gui.Tr.Spans.MoveCommitUp
|
2021-04-10 09:31:23 +02:00
|
|
|
|
2019-02-20 11:51:24 +02:00
|
|
|
selectedCommit := gui.State.Commits[index]
|
|
|
|
if selectedCommit.Status == "rebasing" {
|
2021-04-10 09:31:23 +02:00
|
|
|
// logging directly here because MoveTodoDown doesn't have enough information
|
|
|
|
// to provide a useful log
|
|
|
|
gui.OnRunCommand(oscommands.NewCmdLogEntry(
|
|
|
|
fmt.Sprintf("Moving commit %s up", selectedCommit.ShortSha()),
|
|
|
|
span,
|
|
|
|
false,
|
|
|
|
))
|
|
|
|
|
2019-02-20 11:51:24 +02:00
|
|
|
if err := gui.GitCommand.MoveTodoDown(index - 1); err != nil {
|
2020-03-28 02:47:54 +02:00
|
|
|
return gui.surfaceError(err)
|
2019-02-20 11:51:24 +02:00
|
|
|
}
|
2020-08-20 00:53:10 +02:00
|
|
|
gui.State.Panels.Commits.SelectedLineIdx--
|
2020-08-29 01:52:01 +02:00
|
|
|
return gui.refreshRebaseCommits()
|
2019-02-20 11:51:24 +02:00
|
|
|
}
|
2019-02-18 14:27:54 +02:00
|
|
|
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.MovingStatus, func() error {
|
2021-04-10 09:31:23 +02:00
|
|
|
err := gui.GitCommand.WithSpan(span).MoveCommitDown(gui.State.Commits, index-1)
|
2019-03-03 06:21:33 +02:00
|
|
|
if err == nil {
|
2020-08-20 00:53:10 +02:00
|
|
|
gui.State.Panels.Commits.SelectedLineIdx--
|
2019-03-03 06:21:33 +02:00
|
|
|
}
|
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
2019-02-18 14:27:54 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitEdit() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:36:29 +02:00
|
|
|
applied, err := gui.handleMidRebaseCommand("edit")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.RebasingStatus, func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
err = gui.GitCommand.WithSpan(gui.Tr.Spans.EditCommit).InteractiveRebase(gui.State.Commits, gui.State.Panels.Commits.SelectedLineIdx, "edit")
|
2019-03-03 06:21:33 +02:00
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
2019-02-18 14:27:54 +02:00
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitAmendTo() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.AmendCommitTitle,
|
|
|
|
prompt: gui.Tr.AmendCommitPrompt,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.AmendingStatus, func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
err := gui.GitCommand.WithSpan(gui.Tr.Spans.AmendCommit).AmendTo(gui.State.Commits[gui.State.Panels.Commits.SelectedLineIdx].Sha)
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
})
|
2019-02-19 14:36:29 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitPick() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:36:29 +02:00
|
|
|
applied, err := gui.handleMidRebaseCommand("pick")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if applied {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// at this point we aren't actually rebasing so we will interpret this as an
|
|
|
|
// attempt to pull. We might revoke this later after enabling configurable keybindings
|
2021-04-02 10:20:40 +02:00
|
|
|
return gui.handlePullFiles()
|
2019-02-19 14:36:29 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCommitRevert() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-06-05 08:39:59 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
|
|
|
|
|
|
|
if commit.IsMerge() {
|
|
|
|
return gui.createRevertMergeCommitMenu(commit)
|
|
|
|
} else {
|
|
|
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.RevertCommit).Revert(commit.Sha); err != nil {
|
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
|
|
|
return gui.afterRevertCommit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) createRevertMergeCommitMenu(commit *models.Commit) error {
|
|
|
|
menuItems := make([]*menuItem, len(commit.Parents))
|
|
|
|
for i, parentSha := range commit.Parents {
|
|
|
|
i := i
|
|
|
|
message, err := gui.GitCommand.GetCommitMessageFirstLine(parentSha)
|
|
|
|
if err != nil {
|
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
menuItems[i] = &menuItem{
|
|
|
|
displayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message),
|
|
|
|
onPress: func() error {
|
|
|
|
parentNumber := i + 1
|
|
|
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.RevertCommit).RevertMerge(commit.Sha, parentNumber); err != nil {
|
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
|
|
|
return gui.afterRevertCommit()
|
|
|
|
},
|
|
|
|
}
|
2019-02-19 14:36:29 +02:00
|
|
|
}
|
2021-06-05 08:39:59 +02:00
|
|
|
|
|
|
|
return gui.createMenu(gui.Tr.SelectParentCommitForMerge, menuItems, createMenuOptions{showCancel: true})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) afterRevertCommit() error {
|
2020-08-20 00:53:10 +02:00
|
|
|
gui.State.Panels.Commits.SelectedLineIdx++
|
2021-03-31 14:55:06 +02:00
|
|
|
return gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI, scope: []RefreshableView{COMMITS, BRANCHES}})
|
2019-02-19 14:36:29 +02:00
|
|
|
}
|
2019-02-24 04:51:52 +02:00
|
|
|
|
2020-08-21 01:12:45 +02:00
|
|
|
func (gui *Gui) handleViewCommitFiles() error {
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2020-08-21 01:12:45 +02:00
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-04-03 06:56:11 +02:00
|
|
|
return gui.switchToCommitFilesContext(commit.Sha, true, gui.State.Contexts.BranchCommits, "commits")
|
2019-03-09 16:42:10 +02:00
|
|
|
}
|
2019-03-23 15:46:08 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCreateFixupCommit() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2019-04-07 03:35:34 +02:00
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-04 02:00:48 +02:00
|
|
|
prompt := utils.ResolvePlaceholderString(
|
|
|
|
gui.Tr.SureCreateFixupCommit,
|
|
|
|
map[string]string{
|
|
|
|
"commit": commit.Sha,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.CreateFixupCommit,
|
|
|
|
prompt: prompt,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateFixupCommit).CreateFixupCommit(commit.Sha); err != nil {
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
2019-04-07 03:35:34 +02:00
|
|
|
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
|
|
|
|
},
|
|
|
|
})
|
2019-04-07 03:35:34 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleSquashAllAboveFixupCommits() error {
|
2020-03-29 01:11:15 +02:00
|
|
|
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
2020-03-28 07:28:35 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2019-04-07 03:35:34 +02:00
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-10-04 02:00:48 +02:00
|
|
|
prompt := utils.ResolvePlaceholderString(
|
|
|
|
gui.Tr.SureSquashAboveCommits,
|
|
|
|
map[string]string{
|
|
|
|
"commit": commit.Sha,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.SquashAboveCommits,
|
|
|
|
prompt: prompt,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.WithWaitingStatus(gui.Tr.SquashingStatus, func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
err := gui.GitCommand.WithSpan(gui.Tr.Spans.SquashAllAboveFixupCommits).SquashAllAboveFixupCommits(commit.Sha)
|
2020-08-15 08:36:39 +02:00
|
|
|
return gui.handleGenericMergeCommandResult(err)
|
|
|
|
})
|
2019-04-07 03:35:34 +02:00
|
|
|
},
|
2020-08-15 08:36:39 +02:00
|
|
|
})
|
2019-04-07 03:35:34 +02:00
|
|
|
}
|
2019-04-02 10:53:16 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleTagCommit() error {
|
2019-11-18 00:38:36 +02:00
|
|
|
// TODO: bring up menu asking if you want to make a lightweight or annotated tag
|
|
|
|
// if annotated, switch to a subprocess to create the message
|
|
|
|
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2019-11-18 00:38:36 +02:00
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return gui.handleCreateLightweightTag(commit.Sha)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) handleCreateLightweightTag(commitSha string) error {
|
2020-11-28 04:35:58 +02:00
|
|
|
return gui.prompt(promptOpts{
|
|
|
|
title: gui.Tr.TagNameTitle,
|
|
|
|
handleConfirm: func(response string) error {
|
2021-04-11 11:35:42 +02:00
|
|
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateLightweightTag).CreateLightweightTag(response, commitSha); err != nil {
|
2020-11-28 04:35:58 +02:00
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
2021-03-31 14:55:06 +02:00
|
|
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}})
|
2020-11-28 04:35:58 +02:00
|
|
|
},
|
2019-11-18 00:38:36 +02:00
|
|
|
})
|
|
|
|
}
|
2020-01-07 11:24:10 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCheckoutCommit() error {
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2020-01-07 11:24:10 +02:00
|
|
|
if commit == nil {
|
2020-01-09 13:08:28 +02:00
|
|
|
return nil
|
2020-01-07 11:24:10 +02:00
|
|
|
}
|
|
|
|
|
2020-08-15 08:38:16 +02:00
|
|
|
return gui.ask(askOpts{
|
2020-10-04 02:00:48 +02:00
|
|
|
title: gui.Tr.LcCheckoutCommit,
|
|
|
|
prompt: gui.Tr.SureCheckoutThisCommit,
|
2020-08-15 08:36:39 +02:00
|
|
|
handleConfirm: func() error {
|
2021-04-11 11:35:42 +02:00
|
|
|
return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{span: gui.Tr.Spans.CheckoutCommit})
|
2020-08-15 08:36:39 +02:00
|
|
|
},
|
|
|
|
})
|
2020-01-07 11:24:10 +02:00
|
|
|
}
|
2020-01-09 12:34:17 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleCreateCommitResetMenu() error {
|
2020-08-22 01:48:20 +02:00
|
|
|
commit := gui.getSelectedLocalCommit()
|
2020-02-15 23:59:48 +02:00
|
|
|
if commit == nil {
|
2020-10-04 02:00:48 +02:00
|
|
|
return gui.createErrorPanel(gui.Tr.NoCommitsThisBranch)
|
2020-02-15 23:59:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return gui.createResetMenu(commit.Sha)
|
|
|
|
}
|
2020-02-23 12:53:30 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleOpenSearchForCommitsPanel(_viewName string) error {
|
2020-02-23 13:00:42 +02:00
|
|
|
// we usually lazyload these commits but now that we're searching we need to load them now
|
|
|
|
if gui.State.Panels.Commits.LimitCommits {
|
|
|
|
gui.State.Panels.Commits.LimitCommits = false
|
2021-03-31 14:55:06 +02:00
|
|
|
if err := gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS}}); err != nil {
|
2020-02-23 13:00:42 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
return gui.handleOpenSearch("commits")
|
2020-02-23 13:00:42 +02:00
|
|
|
}
|
2020-03-18 23:45:21 +02:00
|
|
|
|
2021-04-02 10:20:40 +02:00
|
|
|
func (gui *Gui) handleGotoBottomForCommitsPanel() error {
|
2020-03-28 04:57:16 +02:00
|
|
|
// we usually lazyload these commits but now that we're searching we need to load them now
|
|
|
|
if gui.State.Panels.Commits.LimitCommits {
|
|
|
|
gui.State.Panels.Commits.LimitCommits = false
|
2021-03-31 14:55:06 +02:00
|
|
|
if err := gui.refreshSidePanels(refreshOptions{mode: SYNC, scope: []RefreshableView{COMMITS}}); err != nil {
|
2020-03-28 04:57:16 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-17 13:58:30 +02:00
|
|
|
for _, context := range gui.getListContexts() {
|
2021-11-01 00:35:54 +02:00
|
|
|
if context.GetViewName() == "commits" {
|
2021-04-02 10:20:40 +02:00
|
|
|
return context.handleGotoBottom()
|
2020-03-28 04:57:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-10-12 10:13:19 +02:00
|
|
|
|
|
|
|
func (gui *Gui) handleCopySelectedCommitMessageToClipboard() error {
|
|
|
|
commit := gui.getSelectedLocalCommit()
|
|
|
|
if commit == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
message, err := gui.GitCommand.GetCommitMessage(commit.Sha)
|
|
|
|
if err != nil {
|
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
2020-11-21 08:15:43 +02:00
|
|
|
|
2021-04-11 11:35:42 +02:00
|
|
|
if err := gui.OSCommand.WithSpan(gui.Tr.Spans.CopyCommitMessageToClipboard).CopyToClipboard(message); err != nil {
|
2020-11-21 08:15:43 +02:00
|
|
|
return gui.surfaceError(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
gui.raiseToast(gui.Tr.CommitMessageCopiedToClipboard)
|
|
|
|
|
|
|
|
return nil
|
2020-10-12 10:13:19 +02:00
|
|
|
}
|