diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-09-29 18:36:54 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-09-29 20:48:49 +1000 |
commit | 630e4469898cb630c93cd309156c7c90bf2acd75 (patch) | |
tree | 553d9ac059b8d75190821db9c053d8c12f4f02e6 /pkg/gui | |
parent | 44248d9ab0818dfca6a5c1f5ee2ad5b0d45d4998 (diff) |
move commits model into models package
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/cherry_picking.go | 14 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 7 | ||||
-rw-r--r-- | pkg/gui/custom_commands.go | 6 | ||||
-rw-r--r-- | pkg/gui/gui.go | 18 | ||||
-rw-r--r-- | pkg/gui/presentation/commits.go | 10 | ||||
-rw-r--r-- | pkg/gui/presentation/reflog_commits.go | 12 | ||||
-rw-r--r-- | pkg/gui/reflog_panel.go | 8 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 3 |
8 files changed, 39 insertions, 39 deletions
diff --git a/pkg/gui/cherry_picking.go b/pkg/gui/cherry_picking.go index 99da59f98..1355c7d4e 100644 --- a/pkg/gui/cherry_picking.go +++ b/pkg/gui/cherry_picking.go @@ -1,8 +1,6 @@ package gui -import ( - "github.com/jesseduffield/lazygit/pkg/commands" -) +import "github.com/jesseduffield/lazygit/pkg/models" // you can only copy from one context at a time, because the order and position of commits matter @@ -12,7 +10,7 @@ func (gui *Gui) resetCherryPickingIfNecessary(context Context) error { if oldContextKey != context.GetKey() { // need to reset the cherry picking mode gui.State.Modes.CherryPicking.ContextKey = context.GetKey() - gui.State.Modes.CherryPicking.CherryPickedCommits = make([]*commands.Commit, 0) + gui.State.Modes.CherryPicking.CherryPickedCommits = make([]*models.Commit, 0) return gui.rerenderContextViewIfPresent(oldContextKey) } @@ -39,7 +37,7 @@ func (gui *Gui) handleCopyCommit() error { if !ok { return nil } - commit, ok := item.(*commands.Commit) + commit, ok := item.(*models.Commit) if !ok { return nil } @@ -64,7 +62,7 @@ func (gui *Gui) cherryPickedCommitShaMap() map[string]bool { return commitShaMap } -func (gui *Gui) commitsListForContext() []*commands.Commit { +func (gui *Gui) commitsListForContext() []*models.Commit { context := gui.currentSideContext() if context == nil { return nil @@ -89,11 +87,11 @@ func (gui *Gui) addCommitToCherryPickedCommits(index int) { commitsList := gui.commitsListForContext() commitShaMap[commitsList[index].Sha] = true - newCommits := []*commands.Commit{} + newCommits := []*models.Commit{} for _, commit := range commitsList { if commitShaMap[commit.Sha] { // duplicating just the things we need to put in the rebase TODO list - newCommits = append(newCommits, &commands.Commit{Name: commit.Name, Sha: commit.Sha}) + newCommits = append(newCommits, &models.Commit{Name: commit.Name, Sha: commit.Sha}) } } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 541ab465e..4259fb1a2 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -5,11 +5,12 @@ import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/models" ) // list panel functions -func (gui *Gui) getSelectedLocalCommit() *commands.Commit { +func (gui *Gui) getSelectedLocalCommit() *models.Commit { selectedLine := gui.State.Panels.Commits.SelectedLineIdx if selectedLine == -1 { return nil @@ -443,7 +444,7 @@ func (gui *Gui) handleViewCommitFiles() error { return gui.switchToCommitFilesContext(commit.Sha, true, gui.Contexts.BranchCommits.Context, "commits") } -func (gui *Gui) hasCommit(commits []*commands.Commit, target string) (int, bool) { +func (gui *Gui) hasCommit(commits []*models.Commit, target string) (int, bool) { for idx, commit := range commits { if commit.Sha == target { return idx, true @@ -452,7 +453,7 @@ func (gui *Gui) hasCommit(commits []*commands.Commit, target string) (int, bool) return -1, false } -func (gui *Gui) unchooseCommit(commits []*commands.Commit, i int) []*commands.Commit { +func (gui *Gui) unchooseCommit(commits []*models.Commit, i int) []*models.Commit { return append(commits[:i], commits[i+1:]...) } diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 847163f81..1dbad7b2b 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -14,9 +14,9 @@ import ( ) type CustomCommandObjects struct { - SelectedLocalCommit *commands.Commit - SelectedReflogCommit *commands.Commit - SelectedSubCommit *commands.Commit + SelectedLocalCommit *models.Commit + SelectedReflogCommit *models.Commit + SelectedSubCommit *models.Commit SelectedFile *commands.File SelectedLocalBranch *models.Branch SelectedRemoteBranch *commands.RemoteBranch diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index c1d52bee3..ecba887af 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -255,7 +255,7 @@ func (m *Filtering) Active() bool { } type CherryPicking struct { - CherryPickedCommits []*commands.Commit + CherryPickedCommits []*models.Commit // we only allow cherry picking from one context at a time, so you can't copy a commit from the local commits context and then also copy a commit in the reflog context ContextKey string @@ -275,17 +275,17 @@ type guiState struct { Files []*commands.File SubmoduleConfigs []*commands.SubmoduleConfig Branches []*models.Branch - Commits []*commands.Commit + Commits []*models.Commit StashEntries []*commands.StashEntry CommitFiles []*commands.CommitFile // FilteredReflogCommits are the ones that appear in the reflog panel. // when in filtering mode we only include the ones that match the given path - FilteredReflogCommits []*commands.Commit + FilteredReflogCommits []*models.Commit // ReflogCommits are the ones used by the branches panel to obtain recency values // if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be // one and the same - ReflogCommits []*commands.Commit - SubCommits []*commands.Commit + ReflogCommits []*models.Commit + SubCommits []*models.Commit Remotes []*commands.Remote RemoteBranches []*commands.RemoteBranch Tags []*commands.Tag @@ -331,7 +331,7 @@ func (gui *Gui) resetState() { } prevDiff := Diffing{} prevCherryPicking := CherryPicking{ - CherryPickedCommits: make([]*commands.Commit, 0), + CherryPickedCommits: make([]*models.Commit, 0), ContextKey: "", } prevRepoPathStack := []string{} @@ -350,9 +350,9 @@ func (gui *Gui) resetState() { gui.State = &guiState{ Files: make([]*commands.File, 0), - Commits: make([]*commands.Commit, 0), - FilteredReflogCommits: make([]*commands.Commit, 0), - ReflogCommits: make([]*commands.Commit, 0), + Commits: make([]*models.Commit, 0), + FilteredReflogCommits: make([]*models.Commit, 0), + ReflogCommits: make([]*models.Commit, 0), StashEntries: make([]*commands.StashEntry, 0), Panels: &panelStates{ // TODO: work out why some of these are -1 and some are 0. Last time I checked there was a good reason but I'm less certain now diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index ea61a6b26..d66795e7a 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -4,15 +4,15 @@ import ( "strings" "github.com/fatih/color" - "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/models" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/utils" ) -func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string) [][]string { +func GetCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string) [][]string { lines := make([][]string, len(commits)) - var displayFunc func(*commands.Commit, map[string]bool, bool) []string + var displayFunc func(*models.Commit, map[string]bool, bool) []string if fullDescription { displayFunc = getFullDescriptionDisplayStringsForCommit } else { @@ -27,7 +27,7 @@ func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription boo return lines } -func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { +func getFullDescriptionDisplayStringsForCommit(c *models.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { red := color.New(color.FgRed) yellow := color.New(color.FgYellow) green := color.New(color.FgGreen) @@ -76,7 +76,7 @@ func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedC return []string{shaColor.Sprint(c.ShortSha()), secondColumnString, yellow.Sprint(truncatedAuthor), tagString + defaultColor.Sprint(c.Name)} } -func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { +func getDisplayStringsForCommit(c *models.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { red := color.New(color.FgRed) yellow := color.New(color.FgYellow) green := color.New(color.FgGreen) diff --git a/pkg/gui/presentation/reflog_commits.go b/pkg/gui/presentation/reflog_commits.go index b7530e2b9..b7ae68347 100644 --- a/pkg/gui/presentation/reflog_commits.go +++ b/pkg/gui/presentation/reflog_commits.go @@ -2,15 +2,15 @@ package presentation import ( "github.com/fatih/color" - "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/models" "github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/utils" ) -func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string) [][]string { +func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string) [][]string { lines := make([][]string, len(commits)) - var displayFunc func(*commands.Commit, map[string]bool, bool) []string + var displayFunc func(*models.Commit, map[string]bool, bool) []string if fullDescription { displayFunc = getFullDescriptionDisplayStringsForReflogCommit } else { @@ -25,7 +25,7 @@ func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescripti return lines } -func coloredReflogSha(c *commands.Commit, cherryPickedCommitShaMap map[string]bool) string { +func coloredReflogSha(c *models.Commit, cherryPickedCommitShaMap map[string]bool) string { var shaColor *color.Color if cherryPickedCommitShaMap[c.Sha] { shaColor = color.New(color.FgCyan, color.BgBlue) @@ -36,7 +36,7 @@ func coloredReflogSha(c *commands.Commit, cherryPickedCommitShaMap map[string]bo return shaColor.Sprint(c.ShortSha()) } -func getFullDescriptionDisplayStringsForReflogCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { +func getFullDescriptionDisplayStringsForReflogCommit(c *models.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { colorAttr := theme.DefaultTextColor if diffed { colorAttr = theme.DiffTerminalColor @@ -49,7 +49,7 @@ func getFullDescriptionDisplayStringsForReflogCommit(c *commands.Commit, cherryP } } -func getDisplayStringsForReflogCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { +func getDisplayStringsForReflogCommit(c *models.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string { defaultColor := color.New(theme.DefaultTextColor) return []string{ diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go index ed06b3bcc..f00f4c6ed 100644 --- a/pkg/gui/reflog_panel.go +++ b/pkg/gui/reflog_panel.go @@ -2,12 +2,12 @@ package gui import ( "github.com/jesseduffield/gocui" - "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/models" ) // list panel functions -func (gui *Gui) getSelectedReflogCommit() *commands.Commit { +func (gui *Gui) getSelectedReflogCommit() *models.Commit { selectedLine := gui.State.Panels.ReflogCommits.SelectedLineIdx reflogComits := gui.State.FilteredReflogCommits if selectedLine == -1 || len(reflogComits) == 0 { @@ -49,12 +49,12 @@ func (gui *Gui) refreshReflogCommits() error { // pulling state into its own variable incase it gets swapped out for another state // and we get an out of bounds exception state := gui.State - var lastReflogCommit *commands.Commit + var lastReflogCommit *models.Commit if len(state.ReflogCommits) > 0 { lastReflogCommit = state.ReflogCommits[0] } - refresh := func(stateCommits *[]*commands.Commit, filterPath string) error { + refresh := func(stateCommits *[]*models.Commit, filterPath string) error { commits, onlyObtainedNewReflogCommits, err := gui.GitCommand.GetReflogCommits(lastReflogCommit, filterPath) if err != nil { return gui.surfaceError(err) diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index 06793680f..55cfec86c 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -3,11 +3,12 @@ package gui import ( "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" + "github.com/jesseduffield/lazygit/pkg/models" ) // list panel functions -func (gui *Gui) getSelectedSubCommit() *commands.Commit { +func (gui *Gui) getSelectedSubCommit() *models.Commit { selectedLine := gui.State.Panels.SubCommits.SelectedLineIdx commits := gui.State.SubCommits if selectedLine == -1 || len(commits) == 0 { |