1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-07 22:02:56 +03:00

move commit files

This commit is contained in:
Jesse Duffield
2020-09-29 18:48:38 +10:00
parent 91f0b0e28f
commit f9643448a4
6 changed files with 12 additions and 13 deletions

View File

@@ -1120,7 +1120,7 @@ func (c *GitCommand) CherryPickCommits(commits []*models.Commit) error {
} }
// GetFilesInDiff get the specified commit files // GetFilesInDiff get the specified commit files
func (c *GitCommand) GetFilesInDiff(from string, to string, reverse bool, patchManager *patch.PatchManager) ([]*CommitFile, error) { func (c *GitCommand) GetFilesInDiff(from string, to string, reverse bool, patchManager *patch.PatchManager) ([]*models.CommitFile, error) {
reverseFlag := "" reverseFlag := ""
if reverse { if reverse {
reverseFlag = " -R " reverseFlag = " -R "
@@ -1135,8 +1135,8 @@ func (c *GitCommand) GetFilesInDiff(from string, to string, reverse bool, patchM
} }
// filenames string is something like "file1\nfile2\nfile3" // filenames string is something like "file1\nfile2\nfile3"
func (c *GitCommand) GetCommitFilesFromFilenames(filenames string, parent string, patchManager *patch.PatchManager) []*CommitFile { func (c *GitCommand) GetCommitFilesFromFilenames(filenames string, parent string, patchManager *patch.PatchManager) []*models.CommitFile {
commitFiles := make([]*CommitFile, 0) commitFiles := make([]*models.CommitFile, 0)
for _, line := range strings.Split(strings.TrimRight(filenames, "\n"), "\n") { for _, line := range strings.Split(strings.TrimRight(filenames, "\n"), "\n") {
// typical result looks like 'A my_file' meaning my_file was added // typical result looks like 'A my_file' meaning my_file was added
@@ -1150,7 +1150,7 @@ func (c *GitCommand) GetCommitFilesFromFilenames(filenames string, parent string
status = patchManager.GetFileStatus(name) status = patchManager.GetFileStatus(name)
} }
commitFiles = append(commitFiles, &CommitFile{ commitFiles = append(commitFiles, &models.CommitFile{
Parent: parent, Parent: parent,
Name: name, Name: name,
ChangeStatus: changeStatus, ChangeStatus: changeStatus,

View File

@@ -2,10 +2,10 @@ package gui
import ( import (
"github.com/jesseduffield/gocui" "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands" "github.com/jesseduffield/lazygit/pkg/models"
) )
func (gui *Gui) getSelectedCommitFile() *commands.CommitFile { func (gui *Gui) getSelectedCommitFile() *models.CommitFile {
selectedLine := gui.State.Panels.CommitFiles.SelectedLineIdx selectedLine := gui.State.Panels.CommitFiles.SelectedLineIdx
if selectedLine == -1 || selectedLine > len(gui.State.CommitFiles)-1 { if selectedLine == -1 || selectedLine > len(gui.State.CommitFiles)-1 {
return nil return nil

View File

@@ -8,7 +8,6 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/jesseduffield/gocui" "github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/models" "github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
) )
@@ -23,7 +22,7 @@ type CustomCommandObjects struct {
SelectedRemote *models.Remote SelectedRemote *models.Remote
SelectedTag *models.Tag SelectedTag *models.Tag
SelectedStashEntry *models.StashEntry SelectedStashEntry *models.StashEntry
SelectedCommitFile *commands.CommitFile SelectedCommitFile *models.CommitFile
CheckedOutBranch *models.Branch CheckedOutBranch *models.Branch
PromptResponses []string PromptResponses []string
} }

View File

@@ -277,7 +277,7 @@ type guiState struct {
Branches []*models.Branch Branches []*models.Branch
Commits []*models.Commit Commits []*models.Commit
StashEntries []*models.StashEntry StashEntries []*models.StashEntry
CommitFiles []*commands.CommitFile CommitFiles []*models.CommitFile
// FilteredReflogCommits are the ones that appear in the reflog panel. // FilteredReflogCommits are the ones that appear in the reflog panel.
// when in filtering mode we only include the ones that match the given path // when in filtering mode we only include the ones that match the given path
FilteredReflogCommits []*models.Commit FilteredReflogCommits []*models.Commit

View File

@@ -2,13 +2,13 @@ package presentation
import ( import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/models"
"github.com/jesseduffield/lazygit/pkg/theme" "github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
) )
func GetCommitFileListDisplayStrings(commitFiles []*commands.CommitFile, diffName string) [][]string { func GetCommitFileListDisplayStrings(commitFiles []*models.CommitFile, diffName string) [][]string {
if len(commitFiles) == 0 { if len(commitFiles) == 0 {
return [][]string{{utils.ColoredString("(none)", color.FgRed)}} return [][]string{{utils.ColoredString("(none)", color.FgRed)}}
} }
@@ -24,7 +24,7 @@ func GetCommitFileListDisplayStrings(commitFiles []*commands.CommitFile, diffNam
} }
// getCommitFileDisplayStrings returns the display string of branch // getCommitFileDisplayStrings returns the display string of branch
func getCommitFileDisplayStrings(f *commands.CommitFile, diffed bool) []string { func getCommitFileDisplayStrings(f *models.CommitFile, diffed bool) []string {
yellow := color.New(color.FgYellow) yellow := color.New(color.FgYellow)
green := color.New(color.FgGreen) green := color.New(color.FgGreen)
defaultColor := color.New(theme.DefaultTextColor) defaultColor := color.New(theme.DefaultTextColor)

View File

@@ -1,4 +1,4 @@
package commands package models
// CommitFile : A git commit file // CommitFile : A git commit file
type CommitFile struct { type CommitFile struct {