From e849ca337237f564dd90a09e40b9ca8f9d62352a Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Tue, 29 Sep 2020 18:38:56 +1000 Subject: [PATCH] move tags --- pkg/commands/loading_tags.go | 7 ++++--- pkg/gui/custom_commands.go | 2 +- pkg/gui/gui.go | 2 +- pkg/gui/presentation/tags.go | 6 +++--- pkg/gui/tags_panel.go | 4 ++-- pkg/{commands => models}/tag.go | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) rename pkg/{commands => models}/tag.go (92%) diff --git a/pkg/commands/loading_tags.go b/pkg/commands/loading_tags.go index 95ebb450c..c651d9cf2 100644 --- a/pkg/commands/loading_tags.go +++ b/pkg/commands/loading_tags.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" + "github.com/jesseduffield/lazygit/pkg/models" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -19,7 +20,7 @@ func convertToInt(s string) int { return i } -func (c *GitCommand) GetTags() ([]*Tag, error) { +func (c *GitCommand) GetTags() ([]*models.Tag, error) { // get remote branches remoteBranchesStr, err := c.OSCommand.RunCommandWithOutput(`git tag --list`) if err != nil { @@ -34,10 +35,10 @@ func (c *GitCommand) GetTags() ([]*Tag, error) { split := strings.Split(content, "\n") // first step is to get our remotes from go-git - tags := make([]*Tag, len(split)) + tags := make([]*models.Tag, len(split)) for i, tagName := range split { - tags[i] = &Tag{ + tags[i] = &models.Tag{ Name: tagName, } } diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go index 1dbad7b2b..51e929bab 100644 --- a/pkg/gui/custom_commands.go +++ b/pkg/gui/custom_commands.go @@ -21,7 +21,7 @@ type CustomCommandObjects struct { SelectedLocalBranch *models.Branch SelectedRemoteBranch *commands.RemoteBranch SelectedRemote *commands.Remote - SelectedTag *commands.Tag + SelectedTag *models.Tag SelectedStashEntry *commands.StashEntry SelectedCommitFile *commands.CommitFile CheckedOutBranch *models.Branch diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index ecba887af..4028e452b 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -288,7 +288,7 @@ type guiState struct { SubCommits []*models.Commit Remotes []*commands.Remote RemoteBranches []*commands.RemoteBranch - Tags []*commands.Tag + Tags []*models.Tag MenuItems []*menuItem Updating bool Panels *panelStates diff --git a/pkg/gui/presentation/tags.go b/pkg/gui/presentation/tags.go index 475c717cc..0f11b521e 100644 --- a/pkg/gui/presentation/tags.go +++ b/pkg/gui/presentation/tags.go @@ -1,12 +1,12 @@ package presentation import ( - "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 GetTagListDisplayStrings(tags []*commands.Tag, diffName string) [][]string { +func GetTagListDisplayStrings(tags []*models.Tag, diffName string) [][]string { lines := make([][]string, len(tags)) for i := range tags { @@ -18,7 +18,7 @@ func GetTagListDisplayStrings(tags []*commands.Tag, diffName string) [][]string } // getTagDisplayStrings returns the display string of branch -func getTagDisplayStrings(t *commands.Tag, diffed bool) []string { +func getTagDisplayStrings(t *models.Tag, diffed bool) []string { attr := theme.DefaultTextColor if diffed { attr = theme.DiffTerminalColor diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go index 6782ef012..d1ad97168 100644 --- a/pkg/gui/tags_panel.go +++ b/pkg/gui/tags_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) getSelectedTag() *commands.Tag { +func (gui *Gui) getSelectedTag() *models.Tag { selectedLine := gui.State.Panels.Tags.SelectedLineIdx if selectedLine == -1 || len(gui.State.Tags) == 0 { return nil diff --git a/pkg/commands/tag.go b/pkg/models/tag.go similarity index 92% rename from pkg/commands/tag.go rename to pkg/models/tag.go index a51c9660a..2fb024e66 100644 --- a/pkg/commands/tag.go +++ b/pkg/models/tag.go @@ -1,4 +1,4 @@ -package commands +package models // Tag : A git tag type Tag struct {