1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-19 00:28:03 +02:00

move models folder into commands folder

This commit is contained in:
Jesse Duffield
2020-09-29 20:28:39 +10:00
parent 83748d78f8
commit ce6f8ed1bc
50 changed files with 41 additions and 41 deletions

View File

@ -6,8 +6,8 @@ import (
"strconv"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/models"
)
// RenameCommit renames the topmost commit with the given name

View File

@ -7,7 +7,7 @@ import (
"time"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/utils"
)

View File

@ -12,10 +12,10 @@ import (
"github.com/go-errors/errors"
gogit "github.com/go-git/go-git/v5"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/test"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/stretchr/testify/assert"

View File

@ -4,7 +4,7 @@ import (
"regexp"
"strings"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/sirupsen/logrus"
)

View File

@ -3,8 +3,8 @@ package commands
import (
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/models"
)
// GetFilesInDiff get the specified commit files

View File

@ -11,9 +11,9 @@ import (
"strings"
"github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/sirupsen/logrus"
)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/utils"
)

View File

@ -5,8 +5,8 @@ import (
"regexp"
"strconv"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/models"
)
// GetReflogCommits only returns the new reflog commits since the given lastReflogCommit

View File

@ -6,7 +6,7 @@ import (
"sort"
"strings"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
func (c *GitCommand) GetRemotes() ([]*models.Remote, error) {

View File

@ -6,7 +6,7 @@ import (
"strconv"
"strings"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/utils"
)

View File

@ -6,7 +6,7 @@ import (
"strconv"
"strings"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/utils"
)

View File

@ -0,0 +1,26 @@
package models
// Branch : A git branch
// duplicating this for now
type Branch struct {
Name string
// the displayname is something like '(HEAD detached at 123asdf)', whereas in that case the name would be '123asdf'
DisplayName string
Recency string
Pushables string
Pullables string
UpstreamName string
Head bool
}
func (b *Branch) RefName() string {
return b.Name
}
func (b *Branch) ID() string {
return b.RefName()
}
func (b *Branch) Description() string {
return b.RefName()
}

View File

@ -0,0 +1,37 @@
package models
import "fmt"
// Commit : A git commit
type Commit struct {
Sha string
Name string
Status string // one of "unpushed", "pushed", "merged", "rebasing" or "selected"
Action string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup"
Tags []string
ExtraInfo string // something like 'HEAD -> master, tag: v0.15.2'
Author string
UnixTimestamp int64
// IsMerge tells us whether we're dealing with a merge commit i.e. a commit with two parents
IsMerge bool
}
func (c *Commit) ShortSha() string {
if len(c.Sha) < 8 {
return c.Sha
}
return c.Sha[:8]
}
func (c *Commit) RefName() string {
return c.Sha
}
func (c *Commit) ID() string {
return c.RefName()
}
func (c *Commit) Description() string {
return fmt.Sprintf("%s %s", c.Sha[:7], c.Name)
}

View File

@ -0,0 +1,21 @@
package models
// CommitFile : A git commit file
type CommitFile struct {
// Parent is the identifier of the parent object e.g. a commit SHA if this commit file is for a commit, or a stash entry ref like 'stash@{1}'
Parent string
Name string
// PatchStatus tells us whether the file has been wholly or partially added to a patch. We might want to pull this logic up into the gui package and make it a map like we do with cherry picked commits
PatchStatus int // one of 'WHOLE' 'PART' 'NONE'
ChangeStatus string // e.g. 'A' for added or 'M' for modified. This is based on the result from git diff --name-status
}
func (f *CommitFile) ID() string {
return f.Name
}
func (f *CommitFile) Description() string {
return f.Name
}

View File

@ -0,0 +1,60 @@
package models
import (
"strings"
"github.com/jesseduffield/lazygit/pkg/utils"
)
// File : A file from git status
// duplicating this for now
type File struct {
Name string
HasStagedChanges bool
HasUnstagedChanges bool
Tracked bool
Deleted bool
HasMergeConflicts bool
HasInlineMergeConflicts bool
DisplayString string
Type string // one of 'file', 'directory', and 'other'
ShortStatus string // e.g. 'AD', ' A', 'M ', '??'
}
const RENAME_SEPARATOR = " -> "
func (f *File) IsRename() bool {
return strings.Contains(f.Name, RENAME_SEPARATOR)
}
// Names returns an array containing just the filename, or in the case of a rename, the after filename and the before filename
func (f *File) Names() []string {
return strings.Split(f.Name, RENAME_SEPARATOR)
}
// returns true if the file names are the same or if a a file rename includes the filename of the other
func (f *File) Matches(f2 *File) bool {
return utils.StringArraysOverlap(f.Names(), f2.Names())
}
func (f *File) ID() string {
return f.Name
}
func (f *File) Description() string {
return f.Name
}
func (f *File) IsSubmodule(configs []*SubmoduleConfig) bool {
return f.SubmoduleConfig(configs) != nil
}
func (f *File) SubmoduleConfig(configs []*SubmoduleConfig) *SubmoduleConfig {
for _, config := range configs {
if f.Name == config.Name {
return config
}
}
return nil
}

View File

@ -0,0 +1,20 @@
package models
// Remote : A git remote
type Remote struct {
Name string
Urls []string
Branches []*RemoteBranch
}
func (r *Remote) RefName() string {
return r.Name
}
func (r *Remote) ID() string {
return r.RefName()
}
func (r *Remote) Description() string {
return r.RefName()
}

View File

@ -0,0 +1,23 @@
package models
// Remote Branch : A git remote branch
type RemoteBranch struct {
Name string
RemoteName string
}
func (r *RemoteBranch) FullName() string {
return r.RemoteName + "/" + r.Name
}
func (r *RemoteBranch) RefName() string {
return r.FullName()
}
func (r *RemoteBranch) ID() string {
return r.RefName()
}
func (r *RemoteBranch) Description() string {
return r.RefName()
}

View File

@ -0,0 +1,21 @@
package models
import "fmt"
// StashEntry : A git stash entry
type StashEntry struct {
Index int
Name string
}
func (s *StashEntry) RefName() string {
return fmt.Sprintf("stash@{%d}", s.Index)
}
func (s *StashEntry) ID() string {
return s.RefName()
}
func (s *StashEntry) Description() string {
return s.RefName() + ": " + s.Name
}

View File

@ -0,0 +1,7 @@
package models
type SubmoduleConfig struct {
Name string
Path string
Url string
}

View File

@ -0,0 +1,18 @@
package models
// Tag : A git tag
type Tag struct {
Name string
}
func (t *Tag) RefName() string {
return t.Name
}
func (t *Tag) ID() string {
return t.RefName()
}
func (t *Tag) Description() string {
return "tag " + t.Name
}

View File

@ -4,8 +4,8 @@ import (
"fmt"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/models"
)
// DeletePatchesFromCommit applies a patch in reverse for a commit

View File

@ -5,8 +5,8 @@ import (
"strings"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/models"
)
// Service is a service that repository is on (Github, Bitbucket, ...)

View File

@ -5,7 +5,7 @@ import (
"strings"
"testing"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/stretchr/testify/assert"
)

View File

@ -9,7 +9,7 @@ import (
"strings"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/mgutz/str"
)

View File

@ -1,7 +1,7 @@
package commands
import (
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
func (c *GitCommand) AddRemote(name string, url string) error {

View File

@ -5,7 +5,7 @@ import (
"os"
"regexp"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/commands/models"
)
// .gitmodules looks like this: