mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-04 22:34:39 +02:00
Remove calls to Error()
Now that we have an error handler set, we can simply let them bubble up all the way to gocui.
This commit is contained in:
parent
325800a72e
commit
82a3d33ce3
@ -172,7 +172,7 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e
|
||||
func (self *BasicCommitsController) copyCommitHashToClipboard(commit *models.Commit) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyCommitHashToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(commit.Hash); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(fmt.Sprintf("'%s' %s", commit.Hash, self.c.Tr.CopiedToClipboard))
|
||||
@ -182,12 +182,12 @@ func (self *BasicCommitsController) copyCommitHashToClipboard(commit *models.Com
|
||||
func (self *BasicCommitsController) copyCommitURLToClipboard(commit *models.Commit) error {
|
||||
url, err := self.c.Helpers().Host.GetCommitURL(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyCommitURLToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(url); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.CommitURLCopiedToClipboard)
|
||||
@ -197,12 +197,12 @@ func (self *BasicCommitsController) copyCommitURLToClipboard(commit *models.Comm
|
||||
func (self *BasicCommitsController) copyCommitDiffToClipboard(commit *models.Commit) error {
|
||||
diff, err := self.c.Git().Commit.GetCommitDiff(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyCommitDiffToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(diff); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.CommitDiffCopiedToClipboard)
|
||||
@ -212,14 +212,14 @@ func (self *BasicCommitsController) copyCommitDiffToClipboard(commit *models.Com
|
||||
func (self *BasicCommitsController) copyAuthorToClipboard(commit *models.Commit) error {
|
||||
author, err := self.c.Git().Commit.GetCommitAuthor(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
formattedAuthor := fmt.Sprintf("%s <%s>", author.Name, author.Email)
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyCommitAuthorToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(formattedAuthor); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.CommitAuthorCopiedToClipboard)
|
||||
@ -229,12 +229,12 @@ func (self *BasicCommitsController) copyAuthorToClipboard(commit *models.Commit)
|
||||
func (self *BasicCommitsController) copyCommitMessageToClipboard(commit *models.Commit) error {
|
||||
message, err := self.c.Git().Commit.GetCommitMessage(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyCommitMessageToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(message); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.CommitMessageCopiedToClipboard)
|
||||
@ -244,12 +244,12 @@ func (self *BasicCommitsController) copyCommitMessageToClipboard(commit *models.
|
||||
func (self *BasicCommitsController) copyCommitSubjectToClipboard(commit *models.Commit) error {
|
||||
message, err := self.c.Git().Commit.GetCommitSubject(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyCommitSubjectToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(message); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.CommitSubjectCopiedToClipboard)
|
||||
@ -259,12 +259,12 @@ func (self *BasicCommitsController) copyCommitSubjectToClipboard(commit *models.
|
||||
func (self *BasicCommitsController) openInBrowser(commit *models.Commit) error {
|
||||
url, err := self.c.Helpers().Host.GetCommitURL(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.OpenCommitInBrowser)
|
||||
if err := self.c.OS().OpenLink(url); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -96,7 +96,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
||||
if err := self.c.Git().Bisect.Mark(hashToMark, info.NewTerm()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
@ -109,7 +109,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
||||
if err := self.c.Git().Bisect.Mark(hashToMark, info.OldTerm()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
@ -122,7 +122,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
|
||||
if err := self.c.Git().Bisect.Skip(hashToMark); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
@ -137,7 +137,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
|
||||
if err := self.c.Git().Bisect.Skip(commit.Hash); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.afterMark(selectCurrentAfter, waitToReselect)
|
||||
@ -169,11 +169,11 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
||||
if err := self.c.Git().Bisect.Start(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := self.c.Git().Bisect.Mark(commit.Hash, info.NewTerm()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Helpers().Bisect.PostBisectCommandRefresh()
|
||||
@ -186,11 +186,11 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
||||
if err := self.c.Git().Bisect.Start(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := self.c.Git().Bisect.Mark(commit.Hash, info.OldTerm()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Helpers().Bisect.PostBisectCommandRefresh()
|
||||
@ -209,7 +209,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
||||
HandleConfirm: func(newTerm string) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
||||
if err := self.c.Git().Bisect.StartWithTerms(oldTerm, newTerm); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Helpers().Bisect.PostBisectCommandRefresh()
|
||||
@ -232,7 +232,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateHashes []string
|
||||
|
||||
formattedCommits, err := self.c.Git().Commit.GetCommitsOneline(candidateHashes)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Confirm(types.ConfirmOpts{
|
||||
@ -241,7 +241,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateHashes []string
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.ResetBisect)
|
||||
if err := self.c.Git().Bisect.Reset(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Helpers().Bisect.PostBisectCommandRefresh()
|
||||
@ -252,11 +252,11 @@ func (self *BisectController) showBisectCompleteMessage(candidateHashes []string
|
||||
func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) error {
|
||||
done, candidateHashes, err := self.c.Git().Bisect.IsDone()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := self.afterBisectMarkRefresh(selectCurrent, waitToReselect); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if done {
|
||||
|
@ -209,7 +209,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
|
||||
LabelColumns: []string{self.c.Tr.UnsetUpstream},
|
||||
OnPress: func() error {
|
||||
if err := self.c.Git().Branch.UnsetUpstream(selectedBranch.Name); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.Refresh(types.RefreshOptions{
|
||||
Mode: types.SYNC,
|
||||
@ -218,7 +218,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
|
||||
types.COMMITS,
|
||||
},
|
||||
}); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -231,11 +231,11 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
|
||||
return self.c.Helpers().Upstream.PromptForUpstreamWithoutInitialContent(selectedBranch, func(upstream string) error {
|
||||
upstreamRemote, upstreamBranch, err := self.c.Helpers().Upstream.ParseUpstream(upstream)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if err := self.c.Git().Branch.SetUpstream(upstreamRemote, upstreamBranch, selectedBranch.Name); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.Refresh(types.RefreshOptions{
|
||||
Mode: types.SYNC,
|
||||
@ -244,7 +244,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
|
||||
types.COMMITS,
|
||||
},
|
||||
}); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@ -279,7 +279,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
|
||||
OnPress: func() error {
|
||||
err := self.c.Helpers().Refs.CreateGitResetMenu(upstream)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -292,7 +292,7 @@ func (self *BranchesController) viewUpstreamOptions(selectedBranch *models.Branc
|
||||
OpensMenu: true,
|
||||
OnPress: func() error {
|
||||
if err := self.c.Helpers().MergeAndRebase.RebaseOntoRef(selectedBranch.ShortUpstreamRefName()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -395,16 +395,16 @@ func (self *BranchesController) copyPullRequestURL() error {
|
||||
branchExistsOnRemote := self.c.Git().Remote.CheckRemoteBranchExists(branch.Name)
|
||||
|
||||
if !branchExistsOnRemote {
|
||||
return self.c.Error(errors.New(self.c.Tr.NoBranchOnRemote))
|
||||
return errors.New(self.c.Tr.NoBranchOnRemote)
|
||||
}
|
||||
|
||||
url, err := self.c.Helpers().Host.GetPullRequestURL(branch.Name, "")
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyPullRequestURL)
|
||||
if err := self.c.OS().CopyToClipboard(url); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.PullRequestURLCopiedToClipboard)
|
||||
@ -423,7 +423,7 @@ func (self *BranchesController) forceCheckout() error {
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.ForceCheckoutBranch)
|
||||
if err := self.c.Git().Branch.Checkout(branch.Name, git_commands.CheckoutOptions{Force: true}); err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
},
|
||||
@ -463,7 +463,7 @@ func (self *BranchesController) createNewBranchWithName(newBranchName string) er
|
||||
}
|
||||
|
||||
if err := self.c.Git().Branch.New(newBranchName, branch.FullRefName()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.context().SetSelection(0)
|
||||
@ -524,7 +524,7 @@ func (self *BranchesController) localDelete(branch *models.Branch) error {
|
||||
return self.forceDelete(branch)
|
||||
}
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES}})
|
||||
})
|
||||
@ -688,7 +688,7 @@ func (self *BranchesController) rename(branch *models.Branch) error {
|
||||
HandleConfirm: func(newBranchName string) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RenameBranch)
|
||||
if err := self.c.Git().Branch.Rename(branch.Name, helpers.SanitizedBranchName(newBranchName)); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
// need to find where the branch is now so that we can re-select it. That means we need to refetch the branches synchronously and then find our branch
|
||||
@ -783,13 +783,13 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
|
||||
func (self *BranchesController) createPullRequest(from string, to string) error {
|
||||
url, err := self.c.Helpers().Host.GetPullRequestURL(from, to)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.OpenPullRequest)
|
||||
|
||||
if err := self.c.OS().OpenLink(url); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -170,7 +170,7 @@ func (self *CommitFilesController) onClickMain(opts gocui.ViewMouseBindingOpts)
|
||||
func (self *CommitFilesController) checkout(node *filetree.CommitFileNode) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.CheckoutFile)
|
||||
if err := self.c.Git().WorkingTree.CheckoutFile(self.context().GetRef().RefName(), node.GetPath()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
@ -208,7 +208,7 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,7 +294,7 @@ func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.Comm
|
||||
return patchOperationFunction(file.Name)
|
||||
})
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ func (self *ContextLinesController) Context() types.Context {
|
||||
func (self *ContextLinesController) Increase() error {
|
||||
if self.isShowingDiff() {
|
||||
if err := self.checkCanChangeContext(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.AppState.DiffContextSize++
|
||||
@ -80,7 +80,7 @@ func (self *ContextLinesController) Decrease() error {
|
||||
|
||||
if self.isShowingDiff() && old_size > 1 {
|
||||
if err := self.checkCanChangeContext(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.AppState.DiffContextSize = old_size - 1
|
||||
|
@ -234,7 +234,7 @@ func (self *CustomPatchOptionsMenuAction) handleApplyPatch(reverse bool) error {
|
||||
}
|
||||
self.c.LogAction(action)
|
||||
if err := self.c.Git().Patch.ApplyCustomPatch(reverse); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
}
|
||||
@ -244,7 +244,7 @@ func (self *CustomPatchOptionsMenuAction) copyPatchToClipboard() error {
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopyPatchToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(patch); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Toast(self.c.Tr.PatchCopiedToClipboard)
|
||||
|
@ -410,7 +410,7 @@ func (self *FilesController) pressWithLock(selectedNodes []*filetree.FileNode) e
|
||||
}
|
||||
|
||||
if err := self.c.Git().WorkingTree.StageFiles(toPaths(selectedNodes)); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
self.c.LogAction(self.c.Tr.Actions.UnstageFile)
|
||||
@ -428,13 +428,13 @@ func (self *FilesController) pressWithLock(selectedNodes []*filetree.FileNode) e
|
||||
|
||||
if len(untrackedNodes) > 0 {
|
||||
if err := self.c.Git().WorkingTree.UnstageUntrackedFiles(toPaths(untrackedNodes)); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(trackedNodes) > 0 {
|
||||
if err := self.c.Git().WorkingTree.UnstageTrackedFiles(toPaths(trackedNodes)); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -534,7 +534,7 @@ func (self *FilesController) toggleStagedAllWithLock() error {
|
||||
}
|
||||
|
||||
if err := self.c.Git().WorkingTree.StageAll(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
self.c.LogAction(self.c.Tr.Actions.UnstageAllFiles)
|
||||
@ -544,7 +544,7 @@ func (self *FilesController) toggleStagedAllWithLock() error {
|
||||
}
|
||||
|
||||
if err := self.c.Git().WorkingTree.UnstageAll(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -627,7 +627,7 @@ func (self *FilesController) ignoreOrExcludeMenu(node *filetree.FileNode) error
|
||||
LabelColumns: []string{self.c.Tr.IgnoreFile},
|
||||
OnPress: func() error {
|
||||
if err := self.ignore(node); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -637,7 +637,7 @@ func (self *FilesController) ignoreOrExcludeMenu(node *filetree.FileNode) error
|
||||
LabelColumns: []string{self.c.Tr.ExcludeFile},
|
||||
OnPress: func() error {
|
||||
if err := self.exclude(node); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
@ -825,7 +825,7 @@ func (self *FilesController) openCopyMenu() error {
|
||||
Label: self.c.Tr.CopyFileName,
|
||||
OnPress: func() error {
|
||||
if err := self.c.OS().CopyToClipboard(node.Name()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.Toast(self.c.Tr.FileNameCopiedToast)
|
||||
return nil
|
||||
@ -837,7 +837,7 @@ func (self *FilesController) openCopyMenu() error {
|
||||
Label: self.c.Tr.CopyFilePath,
|
||||
OnPress: func() error {
|
||||
if err := self.c.OS().CopyToClipboard(node.Path); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.Toast(self.c.Tr.FilePathCopiedToast)
|
||||
return nil
|
||||
@ -853,10 +853,10 @@ func (self *FilesController) openCopyMenu() error {
|
||||
hasStaged := self.hasPathStagedChanges(node)
|
||||
diff, err := self.c.Git().Diff.GetPathDiff(path, hasStaged)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.OS().CopyToClipboard(diff); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.Toast(self.c.Tr.FileDiffCopiedToast)
|
||||
return nil
|
||||
@ -878,10 +878,10 @@ func (self *FilesController) openCopyMenu() error {
|
||||
hasStaged := self.c.Helpers().WorkingTree.AnyStagedFiles()
|
||||
diff, err := self.c.Git().Diff.GetAllDiff(hasStaged)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.OS().CopyToClipboard(diff); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.Toast(self.c.Tr.AllFilesDiffCopiedToast)
|
||||
return nil
|
||||
@ -957,7 +957,7 @@ func (self *FilesController) handleStashSave(stashFunc func(message string) erro
|
||||
self.c.LogAction(action)
|
||||
|
||||
if err := stashFunc(stashComment); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH, types.FILES}})
|
||||
},
|
||||
@ -975,7 +975,7 @@ func (self *FilesController) onClickSecondary(opts gocui.ViewMouseBindingOpts) e
|
||||
func (self *FilesController) fetch() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.FetchingStatus, func(task gocui.Task) error {
|
||||
if err := self.fetchAux(task); err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
})
|
||||
@ -1073,7 +1073,7 @@ func (self *FilesController) remove(selectedNodes []*filetree.FileNode) error {
|
||||
|
||||
for _, node := range selectedNodes {
|
||||
if err := self.c.Git().WorkingTree.DiscardAllDirChanges(node); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -1101,7 +1101,7 @@ func (self *FilesController) remove(selectedNodes []*filetree.FileNode) error {
|
||||
|
||||
for _, node := range selectedNodes {
|
||||
if err := self.c.Git().WorkingTree.DiscardUnstagedDirChanges(node); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -1127,15 +1127,15 @@ func (self *FilesController) ResetSubmodule(submodule *models.SubmoduleConfig) e
|
||||
file := self.c.Helpers().WorkingTree.FileForSubmodule(submodule)
|
||||
if file != nil {
|
||||
if err := self.c.Git().WorkingTree.UnStageFile(file.Names(), file.Tracked); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := self.c.Git().Submodule.Stash(submodule); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.Git().Submodule.Reset(submodule); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES, types.SUBMODULES}})
|
||||
|
@ -103,7 +103,7 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er
|
||||
func (self *GitFlowController) gitFlowFinishBranch(branchName string) error {
|
||||
cmdObj, err := self.c.Git().Flow.FinishCmdObj(branchName)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.GitFlowFinish)
|
||||
|
@ -63,7 +63,7 @@ func (self *AppStatusHelper) WithWaitingStatus(message string, f func(gocui.Task
|
||||
self.statusMgr().WithWaitingStatus(message, self.renderAppStatus, func(waitingStatusHandle *status.WaitingStatusHandle) {
|
||||
if err := f(appStatusHelperTask{task, waitingStatusHandle}); err != nil {
|
||||
self.c.OnUIThread(func() error {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -19,7 +19,7 @@ func (self *BisectHelper) Reset() error {
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.ResetBisect)
|
||||
if err := self.c.Git().Bisect.Reset(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.PostBisectCommandRefresh()
|
||||
|
@ -37,7 +37,7 @@ func (self *BranchesHelper) ConfirmDeleteRemote(remoteName string, branchName st
|
||||
return self.c.WithWaitingStatus(self.c.Tr.DeletingStatus, func(task gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.DeleteRemoteBranch)
|
||||
if err := self.c.Git().Remote.DeleteRemoteBranch(task, remoteName, branchName); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
|
||||
})
|
||||
|
@ -36,7 +36,7 @@ func (self *ConfirmationHelper) wrappedConfirmationFunction(cancel goContext.Can
|
||||
|
||||
if function != nil {
|
||||
if err := function(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ func (self *FilesHelper) OpenFile(filename string) error {
|
||||
}
|
||||
self.c.LogAction(self.c.Tr.Actions.OpenFile)
|
||||
if err := self.c.OS().OpenFile(absPath); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -45,10 +45,8 @@ func (self *GpgHelper) runAndStream(cmdObj oscommands.ICmdObj, waitingStatus str
|
||||
return self.c.WithWaitingStatus(waitingStatus, func(gocui.Task) error {
|
||||
if err := cmdObj.StreamOutput().Run(); err != nil {
|
||||
_ = self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
return self.c.Error(
|
||||
fmt.Errorf(
|
||||
self.c.Tr.GitCommandFailed, self.c.UserConfig.Keybinding.Universal.ExtrasMenu,
|
||||
),
|
||||
return fmt.Errorf(
|
||||
self.c.Tr.GitCommandFailed, self.c.UserConfig.Keybinding.Universal.ExtrasMenu,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ func (self *InlineStatusHelper) WithInlineStatus(opts InlineStatusOpts, f func(g
|
||||
err := f(inlineStatusHelperTask{task, self, opts})
|
||||
if err != nil {
|
||||
self.c.OnUIThread(func() error {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ func (self *MergeConflictsHelper) RefreshMergeState() error {
|
||||
|
||||
hasConflicts, err := self.SetConflictsAndRender(self.c.Contexts().MergeConflicts.GetState().GetPath())
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if !hasConflicts {
|
||||
|
@ -381,7 +381,7 @@ func (self *RefreshHelper) refreshCommitFilesContext() error {
|
||||
|
||||
files, err := self.c.Git().Loaders.CommitFileLoader.GetFilesInDiff(from, to, reverse)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.Model().CommitFiles = files
|
||||
self.c.Contexts().CommitFiles.CommitFileTreeViewModel.SetTree()
|
||||
@ -406,7 +406,7 @@ func (self *RefreshHelper) refreshRebaseCommits() error {
|
||||
func (self *RefreshHelper) refreshTags() error {
|
||||
tags, err := self.c.Git().Loaders.TagLoader.GetTags()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Model().Tags = tags
|
||||
@ -543,7 +543,7 @@ func (self *RefreshHelper) refreshStateFiles() error {
|
||||
if len(pathsToStage) > 0 {
|
||||
self.c.LogAction(self.c.Tr.Actions.StageResolvedFiles)
|
||||
if err := self.c.Git().WorkingTree.StageFiles(pathsToStage); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ func (self *RefreshHelper) refreshReflogCommits() error {
|
||||
commits, onlyObtainedNewReflogCommits, err := self.c.Git().Loaders.ReflogCommitLoader.
|
||||
GetReflogCommits(lastReflogCommit, filterPath, filterAuthor)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if onlyObtainedNewReflogCommits {
|
||||
@ -634,7 +634,7 @@ func (self *RefreshHelper) refreshRemotes() error {
|
||||
|
||||
remotes, err := self.c.Git().Loaders.RemoteLoader.GetRemotes()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Model().Remotes = remotes
|
||||
|
@ -69,10 +69,10 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions
|
||||
Prompt: self.c.Tr.AutoStashPrompt,
|
||||
HandleConfirm: func() error {
|
||||
if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + ref); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.Git().Branch.Checkout(ref, cmdOptions); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
onSuccess()
|
||||
@ -80,16 +80,14 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions
|
||||
if err := self.c.Refresh(refreshOptions); err != nil {
|
||||
return err
|
||||
}
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(refreshOptions)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
if err := self.c.Error(err); err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
onSuccess()
|
||||
|
||||
@ -142,7 +140,7 @@ func (self *RefsHelper) CheckoutRemoteBranch(fullBranchName string, localBranchN
|
||||
// "git checkout -b", but we want to benefit from all the
|
||||
// nice features of the CheckoutRef function.
|
||||
if err := self.c.Git().Branch.CreateWithUpstream(localBranchName, fullBranchName); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
// Do a sync refresh to make sure the new branch is visible,
|
||||
// so that we see an inline status when checking it out
|
||||
@ -176,7 +174,7 @@ func (self *RefsHelper) GetCheckedOutRef() *models.Branch {
|
||||
|
||||
func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string) error {
|
||||
if err := self.c.Git().Commit.ResetToCommit(ref, strength, envVars); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||
|
@ -25,12 +25,12 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
|
||||
if description != "" {
|
||||
self.c.LogAction(self.c.Tr.Actions.CreateAnnotatedTag)
|
||||
if err := self.c.Git().Tag.CreateAnnotated(tagName, ref, description, force); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
self.c.LogAction(self.c.Tr.Actions.CreateLightweightTag)
|
||||
if err := self.c.Git().Tag.CreateLightweight(tagName, ref, force); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ func (self *UpdateHelper) CheckForUpdateInForeground() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.CheckingForUpdates, func(gocui.Task) error {
|
||||
self.updater.CheckForNewUpdate(func(newVersion string, err error) error {
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if newVersion == "" {
|
||||
return self.c.ErrorMsg(self.c.Tr.FailedToRetrieveLatestVersionErr)
|
||||
|
@ -165,7 +165,7 @@ func (self *WorkingTreeHelper) HandleCommitPress() error {
|
||||
|
||||
func (self *WorkingTreeHelper) WithEnsureCommitableFiles(handler func() error) error {
|
||||
if err := self.prepareFilesForCommit(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if len(self.c.Model().Files) == 0 {
|
||||
@ -186,10 +186,10 @@ func (self *WorkingTreeHelper) promptToStageAllAndRetry(retry func() error) erro
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.StageAllFiles)
|
||||
if err := self.c.Git().WorkingTree.StageAll(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.syncRefresh(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return retry()
|
||||
|
@ -186,7 +186,7 @@ func (self *WorktreeHelper) Remove(worktree *models.Worktree, force bool) error
|
||||
if err := self.c.Git().Worktree.Delete(worktree.Path, force); err != nil {
|
||||
errMessage := err.Error()
|
||||
if !strings.Contains(errMessage, "--force") {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if !force {
|
||||
@ -206,7 +206,7 @@ func (self *WorktreeHelper) Detach(worktree *models.Worktree) error {
|
||||
|
||||
err := self.c.Git().Worktree.Detach(worktree.Path)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.WORKTREES, types.BRANCHES, types.FILES}})
|
||||
})
|
||||
|
@ -352,7 +352,7 @@ func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, star
|
||||
func (self *LocalCommitsController) reword(commit *models.Commit) error {
|
||||
commitMessage, err := self.c.Git().Commit.GetCommitMessage(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if self.c.UserConfig.Git.Commit.AutoWrapCommitMessage {
|
||||
commitMessage = helpers.TryRemoveHardLineBreaks(commitMessage, self.c.UserConfig.Git.Commit.AutoWrapWidth)
|
||||
@ -399,7 +399,7 @@ func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepat
|
||||
func (self *LocalCommitsController) handleReword(summary string, description string) error {
|
||||
err := self.c.Git().Rebase.RewordCommit(self.c.Model().Commits, self.c.Contexts().LocalCommits.GetSelectedLineIdx(), summary, description)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.c.Helpers().Commits.OnCommitSuccess()
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
@ -416,7 +416,7 @@ func (self *LocalCommitsController) doRewordEditor() error {
|
||||
self.c.Model().Commits, self.context().GetSelectedLineIdx(),
|
||||
)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if subProcess != nil {
|
||||
return self.c.RunSubprocessAndRefresh(subProcess)
|
||||
@ -495,7 +495,7 @@ func (self *LocalCommitsController) edit(selectedCommits []*models.Commit) error
|
||||
func (self *LocalCommitsController) quickStartInteractiveRebase() error {
|
||||
commitToEdit, err := self.findCommitForQuickStartInteractiveRebase()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.startInteractiveRebaseWithEdit([]*models.Commit{commitToEdit})
|
||||
@ -587,7 +587,7 @@ func (self *LocalCommitsController) interactiveRebase(action todo.TodoCommand, s
|
||||
// begin a rebase. It then updates the todo file with that action
|
||||
func (self *LocalCommitsController) updateTodos(action todo.TodoCommand, selectedCommits []*models.Commit) error {
|
||||
if err := self.c.Git().Rebase.EditRebaseTodo(selectedCommits, action); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{
|
||||
@ -620,7 +620,7 @@ func (self *LocalCommitsController) isRebasing() bool {
|
||||
func (self *LocalCommitsController) moveDown(selectedCommits []*models.Commit, startIdx int, endIdx int) error {
|
||||
if self.isRebasing() {
|
||||
if err := self.c.Git().Rebase.MoveTodosDown(selectedCommits); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.context().MoveSelection(1)
|
||||
|
||||
@ -643,7 +643,7 @@ func (self *LocalCommitsController) moveDown(selectedCommits []*models.Commit, s
|
||||
func (self *LocalCommitsController) moveUp(selectedCommits []*models.Commit, startIdx int, endIdx int) error {
|
||||
if self.isRebasing() {
|
||||
if err := self.c.Git().Rebase.MoveTodosUp(selectedCommits); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
self.context().MoveSelection(-1)
|
||||
|
||||
@ -733,7 +733,7 @@ func (self *LocalCommitsController) resetAuthor() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.ResetCommitAuthor)
|
||||
if err := self.c.Git().Rebase.ResetCommitAuthor(self.c.Model().Commits, self.context().GetSelectedLineIdx()); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
@ -748,7 +748,7 @@ func (self *LocalCommitsController) setAuthor() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.SetCommitAuthor)
|
||||
if err := self.c.Git().Rebase.SetCommitAuthor(self.c.Model().Commits, self.context().GetSelectedLineIdx(), value); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
@ -765,7 +765,7 @@ func (self *LocalCommitsController) addCoAuthor() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.AmendingStatus, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.AddCommitCoAuthor)
|
||||
if err := self.c.Git().Rebase.AddCommitCoAuthor(self.c.Model().Commits, self.context().GetSelectedLineIdx(), value); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
})
|
||||
@ -803,7 +803,7 @@ func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.C
|
||||
i := i
|
||||
message, err := self.c.Git().Commit.GetCommitMessageFirstLine(parentHash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
menuItems[i] = &types.MenuItem{
|
||||
@ -851,7 +851,7 @@ func (self *LocalCommitsController) createFixupCommit(commit *models.Commit) err
|
||||
self.c.LogAction(self.c.Tr.Actions.CreateFixupCommit)
|
||||
return self.c.WithWaitingStatusSync(self.c.Tr.CreatingFixupCommitStatus, func() error {
|
||||
if err := self.c.Git().Commit.CreateFixupCommit(commit.Hash); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.context().MoveSelectedLine(1)
|
||||
@ -886,7 +886,7 @@ func (self *LocalCommitsController) createFixupCommit(commit *models.Commit) err
|
||||
func (self *LocalCommitsController) createAmendCommit(commit *models.Commit, includeFileChanges bool) error {
|
||||
commitMessage, err := self.c.Git().Commit.GetCommitMessage(commit.Hash)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if self.c.UserConfig.Git.Commit.AutoWrapCommitMessage {
|
||||
commitMessage = helpers.TryRemoveHardLineBreaks(commitMessage, self.c.UserConfig.Git.Commit.AutoWrapWidth)
|
||||
@ -903,7 +903,7 @@ func (self *LocalCommitsController) createAmendCommit(commit *models.Commit, inc
|
||||
self.c.LogAction(self.c.Tr.Actions.CreateFixupCommit)
|
||||
return self.c.WithWaitingStatusSync(self.c.Tr.CreatingFixupCommitStatus, func() error {
|
||||
if err := self.c.Git().Commit.CreateAmendCommit(originalSubject, summary, description, includeFileChanges); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
self.context().MoveSelectedLine(1)
|
||||
@ -944,7 +944,7 @@ func (self *LocalCommitsController) squashAllFixupsAboveSelectedCommit(commit *m
|
||||
func (self *LocalCommitsController) squashAllFixupsInCurrentBranch() error {
|
||||
commit, rebaseStartIdx, err := self.findCommitForSquashFixupsInCurrentBranch()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.squashFixupsImpl(commit, rebaseStartIdx)
|
||||
|
@ -286,7 +286,7 @@ func (self *PatchExplorerController) CopySelectedToClipboard() error {
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.CopySelectedTextToClipboard)
|
||||
if err := self.c.OS().CopyToClipboard(selected); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -169,7 +169,7 @@ func (self *RemoteBranchesController) setAsUpstream(selectedBranch *models.Remot
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.SetBranchUpstream)
|
||||
if err := self.c.Git().Branch.SetUpstream(selectedBranch.RemoteName, selectedBranch.Name, checkedOutBranch.Name); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
|
||||
|
@ -179,7 +179,7 @@ func (self *RemotesController) remove(remote *models.Remote) error {
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RemoveRemote)
|
||||
if err := self.c.Git().Remote.RemoveRemote(remote.Name); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
|
||||
@ -202,7 +202,7 @@ func (self *RemotesController) edit(remote *models.Remote) error {
|
||||
if updatedRemoteName != remote.Name {
|
||||
self.c.LogAction(self.c.Tr.Actions.UpdateRemote)
|
||||
if err := self.c.Git().Remote.RenameRemote(remote.Name, updatedRemoteName); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ func (self *RemotesController) edit(remote *models.Remote) error {
|
||||
HandleConfirm: func(updatedRemoteUrl string) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.UpdateRemote)
|
||||
if err := self.c.Git().Remote.UpdateRemoteUrl(updatedRemoteName, updatedRemoteUrl); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
|
||||
},
|
||||
@ -238,7 +238,7 @@ func (self *RemotesController) fetch(remote *models.Remote) error {
|
||||
return self.c.WithInlineStatus(remote, types.ItemOperationFetching, context.REMOTES_CONTEXT_KEY, func(task gocui.Task) error {
|
||||
err := self.c.Git().Sync.FetchRemote(task, remote.Name)
|
||||
if err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{
|
||||
|
@ -244,7 +244,7 @@ func (self *StagingController) applySelection(reverse bool) error {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if state.SelectingRange() {
|
||||
@ -317,7 +317,7 @@ func (self *StagingController) editHunk() error {
|
||||
Cached: true,
|
||||
},
|
||||
); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -109,7 +109,7 @@ func (self *StashController) handleStashApply(stashEntry *models.StashEntry) err
|
||||
err := self.c.Git().Stash.Apply(stashEntry.Index)
|
||||
_ = self.postStashRefresh()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -133,7 +133,7 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error
|
||||
err := self.c.Git().Stash.Pop(stashEntry.Index)
|
||||
_ = self.postStashRefresh()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -160,7 +160,7 @@ func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) erro
|
||||
err := self.c.Git().Stash.Drop(stashEntry.Index)
|
||||
_ = self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}})
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
@ -163,7 +163,7 @@ func (self *SubmodulesController) add() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.AddSubmodule)
|
||||
err := self.c.Git().Submodule.Add(submoduleName, submodulePath, submoduleUrl)
|
||||
if err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -185,7 +185,7 @@ func (self *SubmodulesController) editURL(submodule *models.SubmoduleConfig) err
|
||||
self.c.LogAction(self.c.Tr.Actions.UpdateSubmoduleUrl)
|
||||
err := self.c.Git().Submodule.UpdateUrl(submodule, newUrl)
|
||||
if err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -199,7 +199,7 @@ func (self *SubmodulesController) init(submodule *models.SubmoduleConfig) error
|
||||
self.c.LogAction(self.c.Tr.Actions.InitialiseSubmodule)
|
||||
err := self.c.Git().Submodule.Init(submodule.Path)
|
||||
if err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -217,7 +217,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BulkInitialiseSubmodules)
|
||||
err := self.c.Git().Submodule.BulkInitCmdObj().Run()
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -231,7 +231,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.RunningCommand, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BulkUpdateSubmodules)
|
||||
if err := self.c.Git().Submodule.BulkUpdateCmdObj().Run(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -245,7 +245,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.RunningCommand, func(gocui.Task) error {
|
||||
self.c.LogAction(self.c.Tr.Actions.BulkDeinitialiseSubmodules)
|
||||
if err := self.c.Git().Submodule.BulkDeinitCmdObj().Run(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -262,7 +262,7 @@ func (self *SubmodulesController) update(submodule *models.SubmoduleConfig) erro
|
||||
self.c.LogAction(self.c.Tr.Actions.UpdateSubmodule)
|
||||
err := self.c.Git().Submodule.Update(submodule.Path)
|
||||
if err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES}})
|
||||
@ -276,7 +276,7 @@ func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) erro
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RemoveSubmodule)
|
||||
if err := self.c.Git().Submodule.Delete(submodule); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES, types.FILES}})
|
||||
|
@ -101,7 +101,7 @@ func (self *SyncController) push(currentBranch *models.Branch) error {
|
||||
return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(currentBranch, func(upstream string) error {
|
||||
upstreamRemote, upstreamBranch, err := self.c.Helpers().Upstream.ParseUpstream(upstream)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.pushAux(currentBranch, pushOpts{
|
||||
@ -121,7 +121,7 @@ func (self *SyncController) pull(currentBranch *models.Branch) error {
|
||||
if !currentBranch.IsTrackingRemote() {
|
||||
return self.c.Helpers().Upstream.PromptForUpstreamWithInitialContent(currentBranch, func(upstream string) error {
|
||||
if err := self.setCurrentBranchUpstream(upstream); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.PullAux(currentBranch, PullFilesOptions{Action: action})
|
||||
|
@ -234,10 +234,7 @@ type hardResetOptions struct {
|
||||
// only to be used in the undo flow for now (does an autostash)
|
||||
func (self *UndoController) hardResetWithAutoStash(commitHash string, options hardResetOptions) error {
|
||||
reset := func() error {
|
||||
if err := self.c.Helpers().Refs.ResetToRef(commitHash, "hard", options.EnvVars); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
return nil
|
||||
return self.c.Helpers().Refs.ResetToRef(commitHash, "hard", options.EnvVars)
|
||||
}
|
||||
|
||||
// if we have any modified tracked files we need to ask the user if they want us to stash for them
|
||||
@ -250,20 +247,17 @@ func (self *UndoController) hardResetWithAutoStash(commitHash string, options ha
|
||||
HandleConfirm: func() error {
|
||||
return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error {
|
||||
if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitHash); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := reset(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := self.c.Git().Stash.Pop(0)
|
||||
if err := self.c.Refresh(types.RefreshOptions{}); err != nil {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
return nil
|
||||
return self.c.Refresh(types.RefreshOptions{})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
@ -31,7 +31,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.NukeWorkingTree)
|
||||
if err := self.c.Git().WorkingTree.ResetAndClean(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if self.c.UserConfig.Gui.AnimateExplosion {
|
||||
@ -53,7 +53,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.DiscardUnstagedFileChanges)
|
||||
if err := self.c.Git().WorkingTree.DiscardAnyUnstagedFileChanges(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(
|
||||
@ -70,7 +70,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RemoveUntrackedFiles)
|
||||
if err := self.c.Git().WorkingTree.RemoveUntrackedFiles(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(
|
||||
@ -91,10 +91,10 @@ func (self *FilesController) createResetMenu() error {
|
||||
return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash)
|
||||
}
|
||||
if err := self.c.Git().Stash.SaveStagedChanges("[lazygit] tmp stash"); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
if err := self.c.Git().Stash.DropNewest(); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(
|
||||
@ -111,7 +111,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.SoftReset)
|
||||
if err := self.c.Git().WorkingTree.ResetSoft("HEAD"); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(
|
||||
@ -128,7 +128,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.MixedReset)
|
||||
if err := self.c.Git().WorkingTree.ResetMixed("HEAD"); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(
|
||||
@ -145,7 +145,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.HardReset)
|
||||
if err := self.c.Git().WorkingTree.ResetHard("HEAD"); err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(
|
||||
|
@ -150,7 +150,7 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboardWithTruncation(maxWi
|
||||
|
||||
gui.c.LogAction(gui.c.Tr.Actions.CopyToClipboard)
|
||||
if err := gui.os.CopyToClipboard(itemId); err != nil {
|
||||
return gui.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
truncatedItemId := utils.TruncateWithEllipsis(strings.Replace(itemId, "\n", " ", -1), 50)
|
||||
|
@ -791,7 +791,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool,
|
||||
defer gui.Mutexes.SubprocessMutex.Unlock()
|
||||
|
||||
if err := gui.g.Suspend(); err != nil {
|
||||
return false, gui.c.Error(err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
gui.BackgroundRoutineMgr.PauseBackgroundRefreshes(true)
|
||||
@ -804,7 +804,7 @@ func (gui *Gui) runSubprocessWithSuspense(subprocess oscommands.ICmdObj) (bool,
|
||||
}
|
||||
|
||||
if cmdErr != nil {
|
||||
return false, gui.c.Error(cmdErr)
|
||||
return false, cmdErr
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
@ -74,7 +74,7 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
|
||||
f = func() error {
|
||||
resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.inputPrompt(resolvedPrompt, wrappedF)
|
||||
}
|
||||
@ -82,7 +82,7 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
|
||||
f = func() error {
|
||||
resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.menuPrompt(resolvedPrompt, wrappedF)
|
||||
}
|
||||
@ -90,7 +90,7 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
|
||||
f = func() error {
|
||||
resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.menuPromptFromCommand(resolvedPrompt, wrappedF)
|
||||
}
|
||||
@ -98,7 +98,7 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
|
||||
f = func() error {
|
||||
resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
return self.confirmPrompt(resolvedPrompt, g)
|
||||
}
|
||||
@ -114,7 +114,7 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
|
||||
func (self *HandlerCreator) inputPrompt(prompt *config.CustomCommandPrompt, wrappedF func(string) error) error {
|
||||
findSuggestionsFn, err := self.generateFindSuggestionsFunc(prompt)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return self.c.Prompt(types.PromptOpts{
|
||||
@ -208,13 +208,13 @@ func (self *HandlerCreator) menuPromptFromCommand(prompt *config.CustomCommandPr
|
||||
// Run and save output
|
||||
message, err := self.c.Git().Custom.RunWithOutput(prompt.Command)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Need to make a menu out of what the cmd has displayed
|
||||
candidates, err := self.menuGenerator.call(message, prompt.Filter, prompt.ValueFormat, prompt.LabelFormat)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
menuItems := lo.Map(candidates, func(candidate *commandMenuItem, _ int) *types.MenuItem {
|
||||
@ -253,7 +253,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
|
||||
resolveTemplate := self.getResolveTemplateFn(form, promptResponses, sessionState)
|
||||
cmdStr, err := resolveTemplate(customCommand.Command)
|
||||
if err != nil {
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
cmdObj := self.c.OS().Cmd.NewShell(cmdStr)
|
||||
@ -284,7 +284,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses
|
||||
return self.mergeAndRebaseHelper.CheckForConflicts(err)
|
||||
}
|
||||
|
||||
return self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if customCommand.ShowOutput {
|
||||
|
Loading…
x
Reference in New Issue
Block a user