mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-07 13:42:01 +02:00
more consistent naming
This commit is contained in:
parent
55af07a1bb
commit
371b8d638b
@ -84,7 +84,7 @@ func (gui *Gui) handleDiscardOldFileChange() error {
|
||||
HandleConfirm: func() error {
|
||||
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
|
||||
gui.c.LogAction(gui.c.Tr.Actions.DiscardOldFileChange)
|
||||
if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Contexts.BranchCommits.GetSelectedLineIdx(), fileName); err != nil {
|
||||
if err := gui.git.Rebase.DiscardOldFileChanges(gui.State.Model.Commits, gui.State.Contexts.LocalCommits.GetSelectedLineIdx(), fileName); err != nil {
|
||||
if err := gui.helpers.MergeAndRebase.CheckMergeOrRebase(err); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -98,7 +98,7 @@ func (gui *Gui) handleDiscardOldFileChange() error {
|
||||
|
||||
func (gui *Gui) refreshCommitFilesView() error {
|
||||
currentSideContext := gui.currentSideContext()
|
||||
if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY {
|
||||
if currentSideContext.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || currentSideContext.GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY {
|
||||
if err := gui.handleRefreshPatchBuildingPanel(-1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ const COMMIT_THRESHOLD = 200
|
||||
// list panel functions
|
||||
|
||||
func (gui *Gui) getSelectedLocalCommit() *models.Commit {
|
||||
return gui.State.Contexts.BranchCommits.GetSelected()
|
||||
return gui.State.Contexts.LocalCommits.GetSelected()
|
||||
}
|
||||
|
||||
func (gui *Gui) onCommitFocus() error {
|
||||
context := gui.State.Contexts.BranchCommits
|
||||
context := gui.State.Contexts.LocalCommits
|
||||
if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() {
|
||||
context.SetLimitCommits(false)
|
||||
go utils.Safe(func() {
|
||||
@ -32,7 +32,7 @@ func (gui *Gui) onCommitFocus() error {
|
||||
|
||||
func (gui *Gui) branchCommitsRenderToMain() error {
|
||||
var task updateTask
|
||||
commit := gui.State.Contexts.BranchCommits.GetSelected()
|
||||
commit := gui.State.Contexts.LocalCommits.GetSelected()
|
||||
if commit == nil {
|
||||
task = NewRenderStringTask(gui.c.Tr.NoCommitsThisBranch)
|
||||
} else {
|
||||
|
@ -336,7 +336,7 @@ func (gui *Gui) currentStaticContext() types.Context {
|
||||
|
||||
func (gui *Gui) defaultSideContext() types.Context {
|
||||
if gui.State.Modes.Filtering.Active() {
|
||||
return gui.State.Contexts.BranchCommits
|
||||
return gui.State.Contexts.LocalCommits
|
||||
} else {
|
||||
return gui.State.Contexts.Files
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ const (
|
||||
REMOTES_CONTEXT_KEY types.ContextKey = "remotes"
|
||||
REMOTE_BRANCHES_CONTEXT_KEY types.ContextKey = "remoteBranches"
|
||||
TAGS_CONTEXT_KEY types.ContextKey = "tags"
|
||||
BRANCH_COMMITS_CONTEXT_KEY types.ContextKey = "commits"
|
||||
LOCAL_COMMITS_CONTEXT_KEY types.ContextKey = "commits"
|
||||
REFLOG_COMMITS_CONTEXT_KEY types.ContextKey = "reflogCommits"
|
||||
SUB_COMMITS_CONTEXT_KEY types.ContextKey = "subCommits"
|
||||
COMMIT_FILES_CONTEXT_KEY types.ContextKey = "commitFiles"
|
||||
@ -41,7 +41,7 @@ var AllContextKeys = []types.ContextKey{
|
||||
REMOTES_CONTEXT_KEY,
|
||||
REMOTE_BRANCHES_CONTEXT_KEY,
|
||||
TAGS_CONTEXT_KEY,
|
||||
BRANCH_COMMITS_CONTEXT_KEY,
|
||||
LOCAL_COMMITS_CONTEXT_KEY,
|
||||
REFLOG_COMMITS_CONTEXT_KEY,
|
||||
SUB_COMMITS_CONTEXT_KEY,
|
||||
COMMIT_FILES_CONTEXT_KEY,
|
||||
@ -67,7 +67,7 @@ type ContextTree struct {
|
||||
Menu *MenuContext
|
||||
Branches *BranchesContext
|
||||
Tags *TagsContext
|
||||
BranchCommits *LocalCommitsContext
|
||||
LocalCommits *LocalCommitsContext
|
||||
CommitFiles *CommitFilesContext
|
||||
Remotes *RemotesContext
|
||||
Submodules *SubmodulesContext
|
||||
@ -97,7 +97,7 @@ func (self *ContextTree) Flatten() []types.Context {
|
||||
self.Remotes,
|
||||
self.RemoteBranches,
|
||||
self.Tags,
|
||||
self.BranchCommits,
|
||||
self.LocalCommits,
|
||||
self.CommitFiles,
|
||||
self.ReflogCommits,
|
||||
self.Stash,
|
||||
@ -170,7 +170,7 @@ func (tree ContextTree) InitialViewTabContextMap() map[string][]TabContext {
|
||||
"commits": {
|
||||
{
|
||||
Tab: "Commits",
|
||||
Contexts: []types.Context{tree.BranchCommits},
|
||||
Contexts: []types.Context{tree.LocalCommits},
|
||||
},
|
||||
{
|
||||
Tab: "Reflog",
|
||||
|
@ -34,7 +34,7 @@ func NewLocalCommitsContext(
|
||||
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
|
||||
ViewName: "commits",
|
||||
WindowName: "commits",
|
||||
Key: BRANCH_COMMITS_CONTEXT_KEY,
|
||||
Key: LOCAL_COMMITS_CONTEXT_KEY,
|
||||
Kind: types.SIDE_CONTEXT,
|
||||
Focusable: true,
|
||||
}), ContextCallbackOpts{
|
||||
|
@ -36,7 +36,7 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
||||
Menu: gui.menuListContext(),
|
||||
Remotes: gui.remotesListContext(),
|
||||
RemoteBranches: gui.remoteBranchesListContext(),
|
||||
BranchCommits: gui.branchCommitsListContext(),
|
||||
LocalCommits: gui.branchCommitsListContext(),
|
||||
CommitFiles: gui.commitFilesListContext(),
|
||||
ReflogCommits: gui.reflogCommitsListContext(),
|
||||
SubCommits: gui.subCommitsListContext(),
|
||||
|
@ -239,5 +239,5 @@ func (self *BisectController) Context() types.Context {
|
||||
}
|
||||
|
||||
func (self *BisectController) context() *context.LocalCommitsContext {
|
||||
return self.contexts.BranchCommits
|
||||
return self.contexts.LocalCommits
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ func (self *CherryPickHelper) resetIfNecessary(context types.Context) error {
|
||||
|
||||
func (self *CherryPickHelper) rerender() error {
|
||||
for _, context := range []types.Context{
|
||||
self.contexts.BranchCommits,
|
||||
self.contexts.LocalCommits,
|
||||
self.contexts.ReflogCommits,
|
||||
self.contexts.SubCommits,
|
||||
} {
|
||||
|
@ -55,9 +55,9 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions
|
||||
onSuccess := func() {
|
||||
self.contexts.Branches.SetSelectedLineIdx(0)
|
||||
self.contexts.ReflogCommits.SetSelectedLineIdx(0)
|
||||
self.contexts.BranchCommits.SetSelectedLineIdx(0)
|
||||
self.contexts.LocalCommits.SetSelectedLineIdx(0)
|
||||
// loading a heap of commits is slow so we limit them whenever doing a reset
|
||||
self.contexts.BranchCommits.SetLimitCommits(true)
|
||||
self.contexts.LocalCommits.SetLimitCommits(true)
|
||||
}
|
||||
|
||||
return self.c.WithWaitingStatus(waitingStatus, func() error {
|
||||
@ -117,12 +117,12 @@ func (self *RefsHelper) ResetToRef(ref string, strength string, envVars []string
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
self.contexts.BranchCommits.SetSelectedLineIdx(0)
|
||||
self.contexts.LocalCommits.SetSelectedLineIdx(0)
|
||||
self.contexts.ReflogCommits.SetSelectedLineIdx(0)
|
||||
// loading a heap of commits is slow so we limit them whenever doing a reset
|
||||
self.contexts.BranchCommits.SetLimitCommits(true)
|
||||
self.contexts.LocalCommits.SetLimitCommits(true)
|
||||
|
||||
if err := self.c.PushContext(self.contexts.BranchCommits); err != nil {
|
||||
if err := self.c.PushContext(self.contexts.LocalCommits); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
|
||||
}
|
||||
}
|
||||
|
||||
self.contexts.BranchCommits.SetSelectedLineIdx(0)
|
||||
self.contexts.LocalCommits.SetSelectedLineIdx(0)
|
||||
self.contexts.Branches.SetSelectedLineIdx(0)
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||
|
@ -746,7 +746,7 @@ func (self *LocalCommitsController) Context() types.Context {
|
||||
}
|
||||
|
||||
func (self *LocalCommitsController) context() *context.LocalCommitsContext {
|
||||
return self.contexts.BranchCommits
|
||||
return self.contexts.LocalCommits
|
||||
}
|
||||
|
||||
func (self *LocalCommitsController) newBranch(commit *models.Commit) error {
|
||||
|
@ -44,7 +44,7 @@ func (gui *Gui) resolveTemplate(templateStr string, promptResponses []string) (s
|
||||
objects := CustomCommandObjects{
|
||||
SelectedFile: gui.getSelectedFile(),
|
||||
SelectedPath: gui.getSelectedPath(),
|
||||
SelectedLocalCommit: gui.State.Contexts.BranchCommits.GetSelected(),
|
||||
SelectedLocalCommit: gui.State.Contexts.LocalCommits.GetSelected(),
|
||||
SelectedReflogCommit: gui.State.Contexts.ReflogCommits.GetSelected(),
|
||||
SelectedLocalBranch: gui.State.Contexts.Branches.GetSelected(),
|
||||
SelectedRemoteBranch: gui.State.Contexts.RemoteBranches.GetSelected(),
|
||||
|
@ -11,7 +11,7 @@ var CONTEXT_KEYS_SHOWING_DIFFS = []types.ContextKey{
|
||||
context.FILES_CONTEXT_KEY,
|
||||
context.COMMIT_FILES_CONTEXT_KEY,
|
||||
context.STASH_CONTEXT_KEY,
|
||||
context.BRANCH_COMMITS_CONTEXT_KEY,
|
||||
context.LOCAL_COMMITS_CONTEXT_KEY,
|
||||
context.SUB_COMMITS_CONTEXT_KEY,
|
||||
context.MAIN_STAGING_CONTEXT_KEY,
|
||||
context.MAIN_PATCH_BUILDING_CONTEXT_KEY,
|
||||
|
@ -46,11 +46,11 @@ func (gui *Gui) setFiltering(path string) error {
|
||||
gui.State.ScreenMode = SCREEN_HALF
|
||||
}
|
||||
|
||||
if err := gui.c.PushContext(gui.State.Contexts.BranchCommits); err != nil {
|
||||
if err := gui.c.PushContext(gui.State.Contexts.LocalCommits); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return gui.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() {
|
||||
gui.State.Contexts.BranchCommits.SetSelectedLineIdx(0)
|
||||
gui.State.Contexts.LocalCommits.SetSelectedLineIdx(0)
|
||||
}})
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ type guiMutexes struct {
|
||||
RefreshingFilesMutex *sync.Mutex
|
||||
RefreshingStatusMutex *sync.Mutex
|
||||
SyncMutex *sync.Mutex
|
||||
BranchCommitsMutex *sync.Mutex
|
||||
LocalCommitsMutex *sync.Mutex
|
||||
LineByLinePanelMutex *sync.Mutex
|
||||
SubprocessMutex *sync.Mutex
|
||||
}
|
||||
@ -337,7 +337,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
|
||||
var initialContext types.IListContext = contextTree.Files
|
||||
if filterPath != "" {
|
||||
screenMode = SCREEN_HALF
|
||||
initialContext = contextTree.BranchCommits
|
||||
initialContext = contextTree.LocalCommits
|
||||
}
|
||||
|
||||
viewContextMap := context.NewViewContextMap()
|
||||
@ -397,7 +397,7 @@ func initialViewContextMapping(contextTree *context.ContextTree) map[string]type
|
||||
"status": contextTree.Status,
|
||||
"files": contextTree.Files,
|
||||
"branches": contextTree.Branches,
|
||||
"commits": contextTree.BranchCommits,
|
||||
"commits": contextTree.LocalCommits,
|
||||
"commitFiles": contextTree.CommitFiles,
|
||||
"stash": contextTree.Stash,
|
||||
"menu": contextTree.Menu,
|
||||
@ -440,7 +440,7 @@ func NewGui(
|
||||
RefreshingFilesMutex: &sync.Mutex{},
|
||||
RefreshingStatusMutex: &sync.Mutex{},
|
||||
SyncMutex: &sync.Mutex{},
|
||||
BranchCommitsMutex: &sync.Mutex{},
|
||||
LocalCommitsMutex: &sync.Mutex{},
|
||||
LineByLinePanelMutex: &sync.Mutex{},
|
||||
SubprocessMutex: &sync.Mutex{},
|
||||
},
|
||||
@ -579,7 +579,7 @@ func (gui *Gui) resetControllers() {
|
||||
controllers.AttachControllers(gui.State.Contexts.Files, gui.Controllers.Files)
|
||||
controllers.AttachControllers(gui.State.Contexts.Tags, gui.Controllers.Tags)
|
||||
controllers.AttachControllers(gui.State.Contexts.Submodules, gui.Controllers.Submodules)
|
||||
controllers.AttachControllers(gui.State.Contexts.BranchCommits, gui.Controllers.LocalCommits, bisectController)
|
||||
controllers.AttachControllers(gui.State.Contexts.LocalCommits, gui.Controllers.LocalCommits, bisectController)
|
||||
controllers.AttachControllers(gui.State.Contexts.Remotes, gui.Controllers.Remotes)
|
||||
controllers.AttachControllers(gui.State.Contexts.Menu, gui.Controllers.Menu)
|
||||
controllers.AttachControllers(gui.State.Contexts.Global, gui.Controllers.Sync, gui.Controllers.Undo, gui.Controllers.Global)
|
||||
|
@ -412,14 +412,14 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
||||
},
|
||||
{
|
||||
ViewName: "commits",
|
||||
Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)},
|
||||
Contexts: []string{string(context.LOCAL_COMMITS_CONTEXT_KEY)},
|
||||
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
|
||||
Handler: self.handleCopySelectedSideContextItemToClipboard,
|
||||
Description: self.c.Tr.LcCopyCommitShaToClipboard,
|
||||
},
|
||||
{
|
||||
ViewName: "commits",
|
||||
Contexts: []string{string(context.BRANCH_COMMITS_CONTEXT_KEY)},
|
||||
Contexts: []string{string(context.LOCAL_COMMITS_CONTEXT_KEY)},
|
||||
Key: opts.GetKey(opts.Config.Commits.ResetCherryPick),
|
||||
Handler: self.helpers.CherryPick.Reset,
|
||||
Description: self.c.Tr.LcResetCherryPick,
|
||||
|
@ -114,8 +114,8 @@ func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext {
|
||||
gui.Views.Commits,
|
||||
func(startIdx int, length int) [][]string {
|
||||
selectedCommitSha := ""
|
||||
if gui.currentContext().GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY {
|
||||
selectedCommit := gui.State.Contexts.BranchCommits.GetSelected()
|
||||
if gui.currentContext().GetKey() == context.LOCAL_COMMITS_CONTEXT_KEY {
|
||||
selectedCommit := gui.State.Contexts.LocalCommits.GetSelected()
|
||||
if selectedCommit != nil {
|
||||
selectedCommitSha = selectedCommit.Sha
|
||||
}
|
||||
@ -266,7 +266,7 @@ func (gui *Gui) submodulesListContext() *context.SubmodulesContext {
|
||||
func (gui *Gui) suggestionsListContext() *context.SuggestionsContext {
|
||||
return context.NewSuggestionsContext(
|
||||
func() []*types.Suggestion { return gui.State.Suggestions },
|
||||
gui.Views.Files,
|
||||
gui.Views.Suggestions,
|
||||
func(startIdx int, length int) [][]string {
|
||||
return presentation.GetSuggestionListDisplayStrings(gui.State.Suggestions)
|
||||
},
|
||||
@ -285,7 +285,7 @@ func (gui *Gui) getListContexts() []types.IListContext {
|
||||
gui.State.Contexts.Remotes,
|
||||
gui.State.Contexts.RemoteBranches,
|
||||
gui.State.Contexts.Tags,
|
||||
gui.State.Contexts.BranchCommits,
|
||||
gui.State.Contexts.LocalCommits,
|
||||
gui.State.Contexts.ReflogCommits,
|
||||
gui.State.Contexts.SubCommits,
|
||||
gui.State.Contexts.Stash,
|
||||
|
@ -44,7 +44,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
||||
},
|
||||
}...)
|
||||
|
||||
if gui.currentContext().GetKey() == gui.State.Contexts.BranchCommits.GetKey() {
|
||||
if gui.currentContext().GetKey() == gui.State.Contexts.LocalCommits.GetKey() {
|
||||
selectedCommit := gui.getSelectedLocalCommit()
|
||||
if selectedCommit != nil && gui.git.Patch.PatchManager.To != selectedCommit.Sha {
|
||||
// adding this option to index 1
|
||||
@ -118,7 +118,7 @@ func (gui *Gui) handleMovePatchToSelectedCommit() error {
|
||||
return gui.c.WithWaitingStatus(gui.c.Tr.RebasingStatus, func() error {
|
||||
commitIndex := gui.getPatchCommitIndex()
|
||||
gui.c.LogAction(gui.c.Tr.Actions.MovePatchToSelectedCommit)
|
||||
err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Model.Commits, commitIndex, gui.State.Contexts.BranchCommits.GetSelectedLineIdx())
|
||||
err := gui.git.Patch.MovePatchToSelectedCommit(gui.State.Model.Commits, commitIndex, gui.State.Contexts.LocalCommits.GetSelectedLineIdx())
|
||||
return gui.helpers.MergeAndRebase.CheckMergeOrRebase(err)
|
||||
})
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ func (gui *Gui) refreshCommits() {
|
||||
go utils.Safe(func() {
|
||||
_ = gui.refreshCommitsWithLimit()
|
||||
ctx, ok := gui.State.Contexts.CommitFiles.GetParentContext()
|
||||
if ok && ctx.GetKey() == context.BRANCH_COMMITS_CONTEXT_KEY {
|
||||
if ok && ctx.GetKey() == context.LOCAL_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.
|
||||
@ -206,16 +206,16 @@ func (gui *Gui) refreshCommits() {
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshCommitsWithLimit() error {
|
||||
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
||||
gui.Mutexes.LocalCommitsMutex.Lock()
|
||||
defer gui.Mutexes.LocalCommitsMutex.Unlock()
|
||||
|
||||
commits, err := gui.git.Loaders.Commits.GetCommits(
|
||||
loaders.GetCommitsOptions{
|
||||
Limit: gui.State.Contexts.BranchCommits.GetLimitCommits(),
|
||||
Limit: gui.State.Contexts.LocalCommits.GetLimitCommits(),
|
||||
FilterPath: gui.State.Modes.Filtering.GetPath(),
|
||||
IncludeRebaseCommits: true,
|
||||
RefName: gui.refForLog(),
|
||||
All: gui.State.Contexts.BranchCommits.GetShowWholeGitGraph(),
|
||||
All: gui.State.Contexts.LocalCommits.GetShowWholeGitGraph(),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@ -223,12 +223,12 @@ func (gui *Gui) refreshCommitsWithLimit() error {
|
||||
}
|
||||
gui.State.Model.Commits = commits
|
||||
|
||||
return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits)
|
||||
return gui.c.PostRefreshUpdate(gui.State.Contexts.LocalCommits)
|
||||
}
|
||||
|
||||
func (gui *Gui) refreshRebaseCommits() error {
|
||||
gui.Mutexes.BranchCommitsMutex.Lock()
|
||||
defer gui.Mutexes.BranchCommitsMutex.Unlock()
|
||||
gui.Mutexes.LocalCommitsMutex.Lock()
|
||||
defer gui.Mutexes.LocalCommitsMutex.Unlock()
|
||||
|
||||
updatedCommits, err := gui.git.Loaders.Commits.MergeRebasingCommits(gui.State.Model.Commits)
|
||||
if err != nil {
|
||||
@ -236,7 +236,7 @@ func (gui *Gui) refreshRebaseCommits() error {
|
||||
}
|
||||
gui.State.Model.Commits = updatedCommits
|
||||
|
||||
return gui.c.PostRefreshUpdate(gui.State.Contexts.BranchCommits)
|
||||
return gui.c.PostRefreshUpdate(gui.State.Contexts.LocalCommits)
|
||||
}
|
||||
|
||||
func (self *Gui) refreshTags() error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user