diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/branch_list_builder.go | 4 | ||||
-rw-r--r-- | pkg/commands/commit_list_builder.go | 35 | ||||
-rw-r--r-- | pkg/commands/git.go | 20 | ||||
-rw-r--r-- | pkg/commands/git_test.go | 8 | ||||
-rw-r--r-- | pkg/commands/patch_rebases.go | 9 | ||||
-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 | ||||
-rw-r--r-- | pkg/models/commit.go (renamed from pkg/commands/commit.go) | 2 |
14 files changed, 79 insertions, 77 deletions
diff --git a/pkg/commands/branch_list_builder.go b/pkg/commands/branch_list_builder.go index 99a27929a..99c60d9c9 100644 --- a/pkg/commands/branch_list_builder.go +++ b/pkg/commands/branch_list_builder.go @@ -24,11 +24,11 @@ import ( type BranchListBuilder struct { Log *logrus.Entry GitCommand *GitCommand - ReflogCommits []*Commit + ReflogCommits []*models.Commit } // NewBranchListBuilder builds a new branch list builder -func NewBranchListBuilder(log *logrus.Entry, gitCommand *GitCommand, reflogCommits []*Commit) (*BranchListBuilder, error) { +func NewBranchListBuilder(log *logrus.Entry, gitCommand *GitCommand, reflogCommits []*models.Commit) (*BranchListBuilder, error) { return &BranchListBuilder{ Log: log, GitCommand: gitCommand, diff --git a/pkg/commands/commit_list_builder.go b/pkg/commands/commit_list_builder.go index 8ba457d30..32b3de0d8 100644 --- a/pkg/commands/commit_list_builder.go +++ b/pkg/commands/commit_list_builder.go @@ -12,6 +12,7 @@ import ( "github.com/fatih/color" "github.com/jesseduffield/lazygit/pkg/i18n" + "github.com/jesseduffield/lazygit/pkg/models" "github.com/sirupsen/logrus" ) @@ -48,7 +49,7 @@ func NewCommitListBuilder(log *logrus.Entry, gitCommand *GitCommand, osCommand * // then puts them into a commit object // example input: // 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag -func (c *CommitListBuilder) extractCommitFromLine(line string) *Commit { +func (c *CommitListBuilder) extractCommitFromLine(line string) *models.Commit { split := strings.Split(line, SEPARATION_CHAR) sha := split[0] @@ -74,7 +75,7 @@ func (c *CommitListBuilder) extractCommitFromLine(line string) *Commit { // If there's a space then it means there must be more than one parent hash isMerge := strings.Contains(parentHashes, " ") - return &Commit{ + return &models.Commit{ Sha: sha, Name: message, Tags: tags, @@ -92,9 +93,9 @@ type GetCommitsOptions struct { RefName string // e.g. "HEAD" or "my_branch" } -func (c *CommitListBuilder) MergeRebasingCommits(commits []*Commit) ([]*Commit, error) { +func (c *CommitListBuilder) MergeRebasingCommits(commits []*models.Commit) ([]*models.Commit, error) { // chances are we have as many commits as last time so we'll set the capacity to be the old length - result := make([]*Commit, 0, len(commits)) + result := make([]*models.Commit, 0, len(commits)) for i, commit := range commits { if commit.Status != "rebasing" { // removing the existing rebase commits so we can add the refreshed ones result = append(result, commits[i:]...) @@ -124,9 +125,9 @@ func (c *CommitListBuilder) MergeRebasingCommits(commits []*Commit) ([]*Commit, } // GetCommits obtains the commits of the current branch -func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*Commit, error) { - commits := []*Commit{} - var rebasingCommits []*Commit +func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit, error) { + commits := []*models.Commit{} + var rebasingCommits []*models.Commit rebaseMode, err := c.GitCommand.RebaseMode() if err != nil { return nil, err @@ -181,7 +182,7 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*Commit, error } // getRebasingCommits obtains the commits that we're in the process of rebasing -func (c *CommitListBuilder) getRebasingCommits(rebaseMode string) ([]*Commit, error) { +func (c *CommitListBuilder) getRebasingCommits(rebaseMode string) ([]*models.Commit, error) { switch rebaseMode { case "normal": return c.getNormalRebasingCommits() @@ -192,7 +193,7 @@ func (c *CommitListBuilder) getRebasingCommits(rebaseMode string) ([]*Commit, er } } -func (c *CommitListBuilder) getNormalRebasingCommits() ([]*Commit, error) { +func (c *CommitListBuilder) getNormalRebasingCommits() ([]*models.Commit, error) { rewrittenCount := 0 bytesContent, err := ioutil.ReadFile(filepath.Join(c.GitCommand.DotGitDir, "rebase-apply/rewritten")) if err == nil { @@ -201,7 +202,7 @@ func (c *CommitListBuilder) getNormalRebasingCommits() ([]*Commit, error) { } // we know we're rebasing, so lets get all the files whose names have numbers - commits := []*Commit{} + commits := []*models.Commit{} err = filepath.Walk(filepath.Join(c.GitCommand.DotGitDir, "rebase-apply"), func(path string, f os.FileInfo, err error) error { if rewrittenCount > 0 { rewrittenCount-- @@ -223,7 +224,7 @@ func (c *CommitListBuilder) getNormalRebasingCommits() ([]*Commit, error) { if err != nil { return err } - commits = append([]*Commit{commit}, commits...) + commits = append([]*models.Commit{commit}, commits...) return nil }) if err != nil { @@ -245,7 +246,7 @@ func (c *CommitListBuilder) getNormalRebasingCommits() ([]*Commit, error) { // getInteractiveRebasingCommits takes our git-rebase-todo and our git-rebase-todo.backup files // and extracts out the sha and names of commits that we still have to go // in the rebase: -func (c *CommitListBuilder) getInteractiveRebasingCommits() ([]*Commit, error) { +func (c *CommitListBuilder) getInteractiveRebasingCommits() ([]*models.Commit, error) { bytesContent, err := ioutil.ReadFile(filepath.Join(c.GitCommand.DotGitDir, "rebase-merge/git-rebase-todo")) if err != nil { c.Log.Error(fmt.Sprintf("error occurred reading git-rebase-todo: %s", err.Error())) @@ -253,7 +254,7 @@ func (c *CommitListBuilder) getInteractiveRebasingCommits() ([]*Commit, error) { return nil, nil } - commits := []*Commit{} + commits := []*models.Commit{} lines := strings.Split(string(bytesContent), "\n") for _, line := range lines { if line == "" || line == "noop" { @@ -263,7 +264,7 @@ func (c *CommitListBuilder) getInteractiveRebasingCommits() ([]*Commit, error) { continue } splitLine := strings.Split(line, " ") - commits = append([]*Commit{{ + commits = append([]*models.Commit{{ Sha: splitLine[1], Name: strings.Join(splitLine[2:], " "), Status: "rebasing", @@ -279,18 +280,18 @@ func (c *CommitListBuilder) getInteractiveRebasingCommits() ([]*Commit, error) { // From: Lazygit Tester <test@example.com> // Date: Wed, 5 Dec 2018 21:03:23 +1100 // Subject: second commit on master -func (c *CommitListBuilder) commitFromPatch(content string) (*Commit, error) { +func (c *CommitListBuilder) commitFromPatch(content string) (*models.Commit, error) { lines := strings.Split(content, "\n") sha := strings.Split(lines[0], " ")[1] name := strings.TrimPrefix(lines[3], "Subject: ") - return &Commit{ + return &models.Commit{ Sha: sha, Name: name, Status: "rebasing", }, nil } -func (c *CommitListBuilder) setCommitMergedStatuses(refName string, commits []*Commit) ([]*Commit, error) { +func (c *CommitListBuilder) setCommitMergedStatuses(refName string, commits []*models.Commit) ([]*models.Commit, error) { ancestor, err := c.getMergeBase(refName) if err != nil { return nil, err diff --git a/pkg/commands/git.go b/pkg/commands/git.go index dcd77f526..d39750951 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -913,7 +913,7 @@ func (c *GitCommand) GenericMerge(commandType string, command string) error { return nil } -func (c *GitCommand) RewordCommit(commits []*Commit, index int) (*exec.Cmd, error) { +func (c *GitCommand) RewordCommit(commits []*models.Commit, index int) (*exec.Cmd, error) { todo, sha, err := c.GenerateGenericRebaseTodo(commits, index, "reword") if err != nil { return nil, err @@ -922,7 +922,7 @@ func (c *GitCommand) RewordCommit(commits []*Commit, index int) (*exec.Cmd, erro return c.PrepareInteractiveRebaseCommand(sha, todo, false) } -func (c *GitCommand) MoveCommitDown(commits []*Commit, index int) error { +func (c *GitCommand) MoveCommitDown(commits []*models.Commit, index int) error { // we must ensure that we have at least two commits after the selected one if len(commits) <= index+2 { // assuming they aren't picking the bottom commit @@ -943,7 +943,7 @@ func (c *GitCommand) MoveCommitDown(commits []*Commit, index int) error { return c.OSCommand.RunPreparedCommand(cmd) } -func (c *GitCommand) InteractiveRebase(commits []*Commit, index int, action string) error { +func (c *GitCommand) InteractiveRebase(commits []*models.Commit, index int, action string) error { todo, sha, err := c.GenerateGenericRebaseTodo(commits, index, action) if err != nil { return err @@ -1005,7 +1005,7 @@ func (c *GitCommand) SoftReset(baseSha string) error { return c.OSCommand.RunCommand("git reset --soft " + baseSha) } -func (c *GitCommand) GenerateGenericRebaseTodo(commits []*Commit, actionIndex int, action string) (string, string, error) { +func (c *GitCommand) GenerateGenericRebaseTodo(commits []*models.Commit, actionIndex int, action string) (string, string, error) { baseIndex := actionIndex + 1 if len(commits) <= baseIndex { @@ -1105,7 +1105,7 @@ func (c *GitCommand) Revert(sha string) error { } // CherryPickCommits begins an interactive rebase with the given shas being cherry picked onto HEAD -func (c *GitCommand) CherryPickCommits(commits []*Commit) error { +func (c *GitCommand) CherryPickCommits(commits []*models.Commit) error { todo := "" for _, commit := range commits { todo = "pick " + commit.Sha + " " + commit.Name + "\n" + todo @@ -1188,7 +1188,7 @@ func (c *GitCommand) CheckoutFile(commitSha, fileName string) error { } // DiscardOldFileChanges discards changes to a file from an old commit -func (c *GitCommand) DiscardOldFileChanges(commits []*Commit, commitIndex int, fileName string) error { +func (c *GitCommand) DiscardOldFileChanges(commits []*models.Commit, commitIndex int, fileName string) error { if err := c.BeginInteractiveRebaseForCommit(commits, commitIndex); err != nil { return err } @@ -1299,7 +1299,7 @@ func (c *GitCommand) StashSaveStagedChanges(message string) error { // BeginInteractiveRebaseForCommit starts an interactive rebase to edit the current // commit and pick all others. After this you'll want to call `c.GenericMerge("rebase", "continue")` -func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*Commit, commitIndex int) error { +func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*models.Commit, commitIndex int) error { if len(commits)-1 < commitIndex { return errors.New("index outside of range of commits") } @@ -1380,8 +1380,8 @@ func (c *GitCommand) FetchRemote(remoteName string) error { // GetReflogCommits only returns the new reflog commits since the given lastReflogCommit // if none is passed (i.e. it's value is nil) then we get all the reflog commits -func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, filterPath string) ([]*Commit, bool, error) { - commits := make([]*Commit, 0) +func (c *GitCommand) GetReflogCommits(lastReflogCommit *models.Commit, filterPath string) ([]*models.Commit, bool, error) { + commits := make([]*models.Commit, 0) re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`) filterPathArg := "" @@ -1399,7 +1399,7 @@ func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, filterPath strin unixTimestamp, _ := strconv.Atoi(match[2]) - commit := &Commit{ + commit := &models.Commit{ Sha: match[1], Name: match[3], UnixTimestamp: int64(unixTimestamp), diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index ab519e9ba..6e7df61aa 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -1716,7 +1716,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { type scenario struct { testName string getLocalGitConfig func(string) (string, error) - commits []*Commit + commits []*models.Commit commitIndex int fileName string command func(string, ...string) *exec.Cmd @@ -1729,7 +1729,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { func(string) (string, error) { return "", nil }, - []*Commit{}, + []*models.Commit{}, 0, "test999.txt", nil, @@ -1742,7 +1742,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { func(string) (string, error) { return "true", nil }, - []*Commit{{Name: "commit", Sha: "123456"}}, + []*models.Commit{{Name: "commit", Sha: "123456"}}, 0, "test999.txt", nil, @@ -1755,7 +1755,7 @@ func TestGitCommandDiscardOldFileChanges(t *testing.T) { func(string) (string, error) { return "", nil }, - []*Commit{ + []*models.Commit{ {Name: "commit", Sha: "123456"}, {Name: "commit2", Sha: "abcdef"}, }, diff --git a/pkg/commands/patch_rebases.go b/pkg/commands/patch_rebases.go index f4d411514..6d032b446 100644 --- a/pkg/commands/patch_rebases.go +++ b/pkg/commands/patch_rebases.go @@ -5,10 +5,11 @@ import ( "github.com/go-errors/errors" "github.com/jesseduffield/lazygit/pkg/commands/patch" + "github.com/jesseduffield/lazygit/pkg/models" ) // DeletePatchesFromCommit applies a patch in reverse for a commit -func (c *GitCommand) DeletePatchesFromCommit(commits []*Commit, commitIndex int, p *patch.PatchManager) error { +func (c *GitCommand) DeletePatchesFromCommit(commits []*models.Commit, commitIndex int, p *patch.PatchManager) error { if err := c.BeginInteractiveRebaseForCommit(commits, commitIndex); err != nil { return err } @@ -35,7 +36,7 @@ func (c *GitCommand) DeletePatchesFromCommit(commits []*Commit, commitIndex int, return c.GenericMerge("rebase", "continue") } -func (c *GitCommand) MovePatchToSelectedCommit(commits []*Commit, sourceCommitIdx int, destinationCommitIdx int, p *patch.PatchManager) error { +func (c *GitCommand) MovePatchToSelectedCommit(commits []*models.Commit, sourceCommitIdx int, destinationCommitIdx int, p *patch.PatchManager) error { if sourceCommitIdx < destinationCommitIdx { if err := c.BeginInteractiveRebaseForCommit(commits, destinationCommitIdx); err != nil { return err @@ -136,7 +137,7 @@ func (c *GitCommand) MovePatchToSelectedCommit(commits []*Commit, sourceCommitId return c.GenericMerge("rebase", "continue") } -func (c *GitCommand) PullPatchIntoIndex(commits []*Commit, commitIdx int, p *patch.PatchManager, stash bool) error { +func (c *GitCommand) PullPatchIntoIndex(commits []*models.Commit, commitIdx int, p *patch.PatchManager, stash bool) error { if stash { if err := c.StashSave(c.Tr.SLocalize("StashPrefix") + commits[commitIdx].Sha); err != nil { return err @@ -189,7 +190,7 @@ func (c *GitCommand) PullPatchIntoIndex(commits []*Commit, commitIdx int, p *pat return c.GenericMerge("rebase", "continue") } -func (c *GitCommand) PullPatchIntoNewCommit(commits []*Commit, commitIdx int, p *patch.PatchManager) error { +func (c *GitCommand) PullPatchIntoNewCommit(commits []*models.Commit, commitIdx int, p *patch.PatchManager) error { if err := c.BeginInteractiveRebaseForCommit(commits, commitIdx); err != nil { return err } 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 { diff --git a/pkg/commands/commit.go b/pkg/models/commit.go index 56e37a967..78cf7f7f7 100644 --- a/pkg/commands/commit.go +++ b/pkg/models/commit.go @@ -1,4 +1,4 @@ -package commands +package models import "fmt" |