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

factor out code from git.go

This commit is contained in:
Jesse Duffield
2020-09-29 20:03:39 +10:00
parent 1767f91047
commit 72af7e4177
19 changed files with 1184 additions and 1128 deletions

View File

@ -8,6 +8,11 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
// GetStatusFiles git status files
type GetStatusFileOptions struct {
NoRenames bool
}
func (c *GitCommand) GetStatusFiles(opts GetStatusFileOptions) []*models.File {
// check if config wants us ignoring untracked files
untrackedFilesSetting := c.GetConfigValue("status.showUntrackedFiles")
@ -82,7 +87,7 @@ func (c *GitCommand) MergeStatusFiles(oldFiles, newFiles []*models.File, selecte
result := []*models.File{}
for _, oldFile := range oldFiles {
for newIndex, newFile := range newFiles {
if includesInt(appendedIndexes, newIndex) {
if utils.IncludesInt(appendedIndexes, newIndex) {
continue
}
// if we just staged B and in doing so created 'A -> B' and we are currently have oldFile: A and newFile: 'A -> B', we want to wait until we come across B so the our cursor isn't jumping anywhere
@ -97,7 +102,7 @@ func (c *GitCommand) MergeStatusFiles(oldFiles, newFiles []*models.File, selecte
// append any new files to the end
for index, newFile := range newFiles {
if !includesInt(appendedIndexes, index) {
if !utils.IncludesInt(appendedIndexes, index) {
result = append(result, newFile)
}
}