mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +02:00
Rename Name to Path in File and CommitFile
Name was very confusing and misleading.
This commit is contained in:
parent
0b5504aa98
commit
2dfc3491bd
@ -55,7 +55,7 @@ func getCommitFilesFromFilenames(filenames string) []*models.CommitFile {
|
|||||||
return lo.Map(lo.Chunk(lines, 2), func(chunk []string, _ int) *models.CommitFile {
|
return lo.Map(lo.Chunk(lines, 2), func(chunk []string, _ int) *models.CommitFile {
|
||||||
return &models.CommitFile{
|
return &models.CommitFile{
|
||||||
ChangeStatus: chunk[0],
|
ChangeStatus: chunk[0],
|
||||||
Name: chunk[1],
|
Path: chunk[1],
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func TestGetCommitFilesFromFilenames(t *testing.T) {
|
|||||||
input: "MM\x00Myfile\x00",
|
input: "MM\x00Myfile\x00",
|
||||||
output: []*models.CommitFile{
|
output: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "Myfile",
|
Path: "Myfile",
|
||||||
ChangeStatus: "MM",
|
ChangeStatus: "MM",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -33,11 +33,11 @@ func TestGetCommitFilesFromFilenames(t *testing.T) {
|
|||||||
input: "MM\x00Myfile\x00M \x00MyOtherFile\x00",
|
input: "MM\x00Myfile\x00M \x00MyOtherFile\x00",
|
||||||
output: []*models.CommitFile{
|
output: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "Myfile",
|
Path: "Myfile",
|
||||||
ChangeStatus: "MM",
|
ChangeStatus: "MM",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "MyOtherFile",
|
Path: "MyOtherFile",
|
||||||
ChangeStatus: "M ",
|
ChangeStatus: "M ",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -47,15 +47,15 @@ func TestGetCommitFilesFromFilenames(t *testing.T) {
|
|||||||
input: "MM\x00Myfile\x00M \x00MyOtherFile\x00 M\x00YetAnother\x00",
|
input: "MM\x00Myfile\x00M \x00MyOtherFile\x00 M\x00YetAnother\x00",
|
||||||
output: []*models.CommitFile{
|
output: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "Myfile",
|
Path: "Myfile",
|
||||||
ChangeStatus: "MM",
|
ChangeStatus: "MM",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "MyOtherFile",
|
Path: "MyOtherFile",
|
||||||
ChangeStatus: "M ",
|
ChangeStatus: "M ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "YetAnother",
|
Path: "YetAnother",
|
||||||
ChangeStatus: " M",
|
ChangeStatus: " M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -68,12 +68,12 @@ func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File
|
|||||||
}
|
}
|
||||||
|
|
||||||
file := &models.File{
|
file := &models.File{
|
||||||
Name: status.Name,
|
Path: status.Path,
|
||||||
PreviousName: status.PreviousName,
|
PreviousPath: status.PreviousPath,
|
||||||
DisplayString: status.StatusString,
|
DisplayString: status.StatusString,
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff, ok := fileDiffs[status.Name]; ok {
|
if diff, ok := fileDiffs[status.Path]; ok {
|
||||||
file.LinesAdded = diff.LinesAdded
|
file.LinesAdded = diff.LinesAdded
|
||||||
file.LinesDeleted = diff.LinesDeleted
|
file.LinesDeleted = diff.LinesDeleted
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File
|
|||||||
worktreePaths := linkedWortkreePaths(self.Fs, self.repoPaths.RepoGitDirPath())
|
worktreePaths := linkedWortkreePaths(self.Fs, self.repoPaths.RepoGitDirPath())
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
for _, worktreePath := range worktreePaths {
|
for _, worktreePath := range worktreePaths {
|
||||||
absFilePath, err := filepath.Abs(file.Name)
|
absFilePath, err := filepath.Abs(file.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.Log.Error(err)
|
self.Log.Error(err)
|
||||||
continue
|
continue
|
||||||
@ -96,7 +96,7 @@ func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File
|
|||||||
file.IsWorktree = true
|
file.IsWorktree = true
|
||||||
// `git status` renders this worktree as a folder with a trailing slash but we'll represent it as a singular worktree
|
// `git status` renders this worktree as a folder with a trailing slash but we'll represent it as a singular worktree
|
||||||
// If we include the slash, it will be rendered as a folder with a null file inside.
|
// If we include the slash, it will be rendered as a folder with a null file inside.
|
||||||
file.Name = strings.TrimSuffix(file.Name, "/")
|
file.Path = strings.TrimSuffix(file.Path, "/")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,8 +153,8 @@ type GitStatusOptions struct {
|
|||||||
type FileStatus struct {
|
type FileStatus struct {
|
||||||
StatusString string
|
StatusString string
|
||||||
Change string // ??, MM, AM, ...
|
Change string // ??, MM, AM, ...
|
||||||
Name string
|
Path string
|
||||||
PreviousName string
|
PreviousPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fileLoader *FileLoader) gitDiffNumStat() (string, error) {
|
func (fileLoader *FileLoader) gitDiffNumStat() (string, error) {
|
||||||
@ -197,14 +197,14 @@ func (self *FileLoader) gitStatus(opts GitStatusOptions) ([]FileStatus, error) {
|
|||||||
status := FileStatus{
|
status := FileStatus{
|
||||||
StatusString: original,
|
StatusString: original,
|
||||||
Change: original[:2],
|
Change: original[:2],
|
||||||
Name: original[3:],
|
Path: original[3:],
|
||||||
PreviousName: "",
|
PreviousPath: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(status.Change, "R") {
|
if strings.HasPrefix(status.Change, "R") {
|
||||||
// if a line starts with 'R' then the next line is the original file.
|
// if a line starts with 'R' then the next line is the original file.
|
||||||
status.PreviousName = splitLines[i+1]
|
status.PreviousPath = splitLines[i+1]
|
||||||
status.StatusString = fmt.Sprintf("%s %s -> %s", status.Change, status.PreviousName, status.Name)
|
status.StatusString = fmt.Sprintf("%s %s -> %s", status.Change, status.PreviousPath, status.Path)
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
showNumstatInFilesView: true,
|
showNumstatInFilesView: true,
|
||||||
expectedFiles: []*models.File{
|
expectedFiles: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "file1.txt",
|
Path: "file1.txt",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
@ -55,7 +55,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
LinesDeleted: 1,
|
LinesDeleted: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "file3.txt",
|
Path: "file3.txt",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
HasUnstagedChanges: false,
|
HasUnstagedChanges: false,
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
@ -69,7 +69,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
LinesDeleted: 2,
|
LinesDeleted: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "file2.txt",
|
Path: "file2.txt",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
@ -83,7 +83,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
LinesDeleted: 0,
|
LinesDeleted: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "file4.txt",
|
Path: "file4.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
@ -97,7 +97,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
LinesDeleted: 2,
|
LinesDeleted: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "file5.txt",
|
Path: "file5.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
@ -119,7 +119,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, "MM a\nb.txt", nil),
|
ExpectGitArgs([]string{"status", "--untracked-files=yes", "--porcelain", "-z", "--find-renames=50%"}, "MM a\nb.txt", nil),
|
||||||
expectedFiles: []*models.File{
|
expectedFiles: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "a\nb.txt",
|
Path: "a\nb.txt",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
@ -142,8 +142,8 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
),
|
),
|
||||||
expectedFiles: []*models.File{
|
expectedFiles: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "after1.txt",
|
Path: "after1.txt",
|
||||||
PreviousName: "before1.txt",
|
PreviousPath: "before1.txt",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
HasUnstagedChanges: false,
|
HasUnstagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
@ -155,8 +155,8 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
ShortStatus: "R ",
|
ShortStatus: "R ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "after2.txt",
|
Path: "after2.txt",
|
||||||
PreviousName: "before2.txt",
|
PreviousPath: "before2.txt",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
@ -179,7 +179,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
|||||||
),
|
),
|
||||||
expectedFiles: []*models.File{
|
expectedFiles: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "a -> b.txt",
|
Path: "a -> b.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
HasUnstagedChanges: true,
|
HasUnstagedChanges: true,
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
|
@ -92,11 +92,11 @@ func (self *WorkingTreeCommands) BeforeAndAfterFileForRename(file *models.File)
|
|||||||
var beforeFile *models.File
|
var beforeFile *models.File
|
||||||
var afterFile *models.File
|
var afterFile *models.File
|
||||||
for _, f := range filesWithoutRenames {
|
for _, f := range filesWithoutRenames {
|
||||||
if f.Name == file.PreviousName {
|
if f.Path == file.PreviousPath {
|
||||||
beforeFile = f
|
beforeFile = f
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.Name == file.Name {
|
if f.Path == file.Path {
|
||||||
afterFile = f
|
afterFile = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,13 +134,13 @@ func (self *WorkingTreeCommands) DiscardAllFileChanges(file *models.File) error
|
|||||||
|
|
||||||
if file.ShortStatus == "AA" {
|
if file.ShortStatus == "AA" {
|
||||||
if err := self.cmd.New(
|
if err := self.cmd.New(
|
||||||
NewGitCmd("checkout").Arg("--ours", "--", file.Name).ToArgv(),
|
NewGitCmd("checkout").Arg("--ours", "--", file.Path).ToArgv(),
|
||||||
).Run(); err != nil {
|
).Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.cmd.New(
|
if err := self.cmd.New(
|
||||||
NewGitCmd("add").Arg("--", file.Name).ToArgv(),
|
NewGitCmd("add").Arg("--", file.Path).ToArgv(),
|
||||||
).Run(); err != nil {
|
).Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -149,14 +149,14 @@ func (self *WorkingTreeCommands) DiscardAllFileChanges(file *models.File) error
|
|||||||
|
|
||||||
if file.ShortStatus == "DU" {
|
if file.ShortStatus == "DU" {
|
||||||
return self.cmd.New(
|
return self.cmd.New(
|
||||||
NewGitCmd("rm").Arg("--", file.Name).ToArgv(),
|
NewGitCmd("rm").Arg("--", file.Path).ToArgv(),
|
||||||
).Run()
|
).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the file isn't tracked, we assume you want to delete it
|
// if the file isn't tracked, we assume you want to delete it
|
||||||
if file.HasStagedChanges || file.HasMergeConflicts {
|
if file.HasStagedChanges || file.HasMergeConflicts {
|
||||||
if err := self.cmd.New(
|
if err := self.cmd.New(
|
||||||
NewGitCmd("reset").Arg("--", file.Name).ToArgv(),
|
NewGitCmd("reset").Arg("--", file.Path).ToArgv(),
|
||||||
).Run(); err != nil {
|
).Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ func (self *WorkingTreeCommands) DiscardAllFileChanges(file *models.File) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file.Added {
|
if file.Added {
|
||||||
return self.os.RemoveFile(file.Name)
|
return self.os.RemoveFile(file.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.DiscardUnstagedFileChanges(file)
|
return self.DiscardUnstagedFileChanges(file)
|
||||||
@ -199,7 +199,7 @@ func (self *WorkingTreeCommands) DiscardUnstagedDirChanges(node IFileNode) error
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if file.Added && !file.HasStagedChanges {
|
if file.Added && !file.HasStagedChanges {
|
||||||
return self.os.RemoveFile(file.Name)
|
return self.os.RemoveFile(file.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.DiscardUnstagedFileChanges(file); err != nil {
|
if err := self.DiscardUnstagedFileChanges(file); err != nil {
|
||||||
@ -226,7 +226,7 @@ func (self *WorkingTreeCommands) RemoveUntrackedDirFiles(node IFileNode) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *WorkingTreeCommands) DiscardUnstagedFileChanges(file *models.File) error {
|
func (self *WorkingTreeCommands) DiscardUnstagedFileChanges(file *models.File) error {
|
||||||
cmdArgs := NewGitCmd("checkout").Arg("--", file.Name).ToArgv()
|
cmdArgs := NewGitCmd("checkout").Arg("--", file.Path).ToArgv()
|
||||||
return self.cmd.New(cmdArgs).Run()
|
return self.cmd.New(cmdArgs).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "An error occurred when resetting",
|
testName: "An error occurred when resetting",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
},
|
},
|
||||||
removeFile: func(string) error { return nil },
|
removeFile: func(string) error { return nil },
|
||||||
@ -94,7 +94,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "An error occurred when removing file",
|
testName: "An error occurred when removing file",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
Added: true,
|
Added: true,
|
||||||
},
|
},
|
||||||
@ -107,7 +107,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "An error occurred with checkout",
|
testName: "An error occurred with checkout",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
},
|
},
|
||||||
@ -119,7 +119,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Checkout only",
|
testName: "Checkout only",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
},
|
},
|
||||||
@ -131,7 +131,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Reset and checkout staged changes",
|
testName: "Reset and checkout staged changes",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
},
|
},
|
||||||
@ -144,7 +144,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Reset and checkout merge conflicts",
|
testName: "Reset and checkout merge conflicts",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
HasMergeConflicts: true,
|
HasMergeConflicts: true,
|
||||||
},
|
},
|
||||||
@ -157,7 +157,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Reset and remove",
|
testName: "Reset and remove",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
Added: true,
|
Added: true,
|
||||||
HasStagedChanges: true,
|
HasStagedChanges: true,
|
||||||
@ -173,7 +173,7 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Remove only",
|
testName: "Remove only",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test",
|
Path: "test",
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
Added: true,
|
Added: true,
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
@ -220,7 +220,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Default case",
|
testName: "Default case",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
@ -235,7 +235,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "cached",
|
testName: "cached",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
@ -250,7 +250,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "plain",
|
testName: "plain",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
@ -265,7 +265,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "File not tracked and file has no staged changes",
|
testName: "File not tracked and file has no staged changes",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
},
|
},
|
||||||
@ -280,7 +280,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Default case (ignore whitespace)",
|
testName: "Default case (ignore whitespace)",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
@ -295,7 +295,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Show diff with custom context size",
|
testName: "Show diff with custom context size",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
@ -310,7 +310,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
|||||||
{
|
{
|
||||||
testName: "Show diff with custom similarity threshold",
|
testName: "Show diff with custom similarity threshold",
|
||||||
file: &models.File{
|
file: &models.File{
|
||||||
Name: "test.txt",
|
Path: "test.txt",
|
||||||
HasStagedChanges: false,
|
HasStagedChanges: false,
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
@ -466,7 +466,7 @@ func TestWorkingTreeDiscardUnstagedFileChanges(t *testing.T) {
|
|||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
testName: "valid case",
|
testName: "valid case",
|
||||||
file: &models.File{Name: "test.txt"},
|
file: &models.File{Path: "test.txt"},
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
ExpectGitArgs([]string{"checkout", "--", "test.txt"}, "", nil),
|
ExpectGitArgs([]string{"checkout", "--", "test.txt"}, "", nil),
|
||||||
test: func(err error) {
|
test: func(err error) {
|
||||||
|
@ -2,18 +2,17 @@ package models
|
|||||||
|
|
||||||
// CommitFile : A git commit file
|
// CommitFile : A git commit file
|
||||||
type CommitFile struct {
|
type CommitFile struct {
|
||||||
// TODO: rename this to Path
|
Path string
|
||||||
Name string
|
|
||||||
|
|
||||||
ChangeStatus string // e.g. 'A' for added or 'M' for modified. This is based on the result from git diff --name-status
|
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 {
|
func (f *CommitFile) ID() string {
|
||||||
return f.Name
|
return f.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *CommitFile) Description() string {
|
func (f *CommitFile) Description() string {
|
||||||
return f.Name
|
return f.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *CommitFile) Added() bool {
|
func (f *CommitFile) Added() bool {
|
||||||
@ -25,5 +24,5 @@ func (f *CommitFile) Deleted() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *CommitFile) GetPath() string {
|
func (f *CommitFile) GetPath() string {
|
||||||
return f.Name
|
return f.Path
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
// File : A file from git status
|
// File : A file from git status
|
||||||
// duplicating this for now
|
// duplicating this for now
|
||||||
type File struct {
|
type File struct {
|
||||||
Name string
|
Path string
|
||||||
PreviousName string
|
PreviousPath string
|
||||||
HasStagedChanges bool
|
HasStagedChanges bool
|
||||||
HasUnstagedChanges bool
|
HasUnstagedChanges bool
|
||||||
Tracked bool
|
Tracked bool
|
||||||
@ -37,14 +37,14 @@ type IFile interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) IsRename() bool {
|
func (f *File) IsRename() bool {
|
||||||
return f.PreviousName != ""
|
return f.PreviousPath != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Names returns an array containing just the filename, or in the case of a rename, the after filename and the before filename
|
// 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 {
|
func (f *File) Names() []string {
|
||||||
result := []string{f.Name}
|
result := []string{f.Path}
|
||||||
if f.PreviousName != "" {
|
if f.PreviousPath != "" {
|
||||||
result = append(result, f.PreviousName)
|
result = append(result, f.PreviousPath)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@ -55,11 +55,11 @@ func (f *File) Matches(f2 *File) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) ID() string {
|
func (f *File) ID() string {
|
||||||
return f.Name
|
return f.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) Description() string {
|
func (f *File) Description() string {
|
||||||
return f.Name
|
return f.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) IsSubmodule(configs []*SubmoduleConfig) bool {
|
func (f *File) IsSubmodule(configs []*SubmoduleConfig) bool {
|
||||||
@ -68,7 +68,7 @@ func (f *File) IsSubmodule(configs []*SubmoduleConfig) bool {
|
|||||||
|
|
||||||
func (f *File) SubmoduleConfig(configs []*SubmoduleConfig) *SubmoduleConfig {
|
func (f *File) SubmoduleConfig(configs []*SubmoduleConfig) *SubmoduleConfig {
|
||||||
for _, config := range configs {
|
for _, config := range configs {
|
||||||
if f.Name == config.Path {
|
if f.Path == config.Path {
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,11 +90,11 @@ func (f *File) GetIsTracked() bool {
|
|||||||
|
|
||||||
func (f *File) GetPath() string {
|
func (f *File) GetPath() string {
|
||||||
// TODO: remove concept of name; just use path
|
// TODO: remove concept of name; just use path
|
||||||
return f.Name
|
return f.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) GetPreviousPath() string {
|
func (f *File) GetPreviousPath() string {
|
||||||
return f.PreviousName
|
return f.PreviousPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) GetIsFile() bool {
|
func (f *File) GetIsFile() bool {
|
||||||
|
@ -402,7 +402,7 @@ func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.Comm
|
|||||||
// Find if any file in the selection is unselected or partially added
|
// Find if any file in the selection is unselected or partially added
|
||||||
adding := lo.SomeBy(selectedNodes, func(node *filetree.CommitFileNode) bool {
|
adding := lo.SomeBy(selectedNodes, func(node *filetree.CommitFileNode) bool {
|
||||||
return node.SomeFile(func(file *models.CommitFile) bool {
|
return node.SomeFile(func(file *models.CommitFile) bool {
|
||||||
fileStatus := self.c.Git().Patch.PatchBuilder.GetFileStatus(file.Name, self.context().GetRef().RefName())
|
fileStatus := self.c.Git().Patch.PatchBuilder.GetFileStatus(file.Path, self.context().GetRef().RefName())
|
||||||
return fileStatus == patch.PART || fileStatus == patch.UNSELECTED
|
return fileStatus == patch.PART || fileStatus == patch.UNSELECTED
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -415,7 +415,7 @@ func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.Comm
|
|||||||
|
|
||||||
for _, node := range selectedNodes {
|
for _, node := range selectedNodes {
|
||||||
err := node.ForEachFile(func(file *models.CommitFile) error {
|
err := node.ForEachFile(func(file *models.CommitFile) error {
|
||||||
return patchOperationFunction(file.Name)
|
return patchOperationFunction(file.Path)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -372,7 +372,7 @@ func (self *FilesController) optimisticChange(nodes []*filetree.FileNode, optimi
|
|||||||
err := node.ForEachFile(func(f *models.File) error {
|
err := node.ForEachFile(func(f *models.File) error {
|
||||||
// can't act on the file itself: we need to update the original model file
|
// can't act on the file itself: we need to update the original model file
|
||||||
for _, modelFile := range self.c.Model().Files {
|
for _, modelFile := range self.c.Model().Files {
|
||||||
if modelFile.Name == f.Name {
|
if modelFile.Path == f.Path {
|
||||||
if optimisticChangeFn(modelFile) {
|
if optimisticChangeFn(modelFile) {
|
||||||
rerender = true
|
rerender = true
|
||||||
}
|
}
|
||||||
@ -897,7 +897,7 @@ func (self *FilesController) switchToMerge() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Helpers().MergeConflicts.SwitchToMerge(file.Name)
|
return self.c.Helpers().MergeConflicts.SwitchToMerge(file.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *FilesController) createStashMenu() error {
|
func (self *FilesController) createStashMenu() error {
|
||||||
|
@ -554,11 +554,11 @@ func (self *RefreshHelper) refreshStateFiles() error {
|
|||||||
prevConflictFileCount++
|
prevConflictFileCount++
|
||||||
}
|
}
|
||||||
if file.HasInlineMergeConflicts {
|
if file.HasInlineMergeConflicts {
|
||||||
hasConflicts, err := mergeconflicts.FileHasConflictMarkers(file.Name)
|
hasConflicts, err := mergeconflicts.FileHasConflictMarkers(file.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
self.c.Log.Error(err)
|
self.c.Log.Error(err)
|
||||||
} else if !hasConflicts {
|
} else if !hasConflicts {
|
||||||
pathsToStage = append(pathsToStage, file.Name)
|
pathsToStage = append(pathsToStage, file.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ func BuildTreeFromFiles(files []*models.File) *Node[models.File] {
|
|||||||
|
|
||||||
var curr *Node[models.File]
|
var curr *Node[models.File]
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
splitPath := split(file.Name)
|
splitPath := split(file.Path)
|
||||||
curr = root
|
curr = root
|
||||||
outer:
|
outer:
|
||||||
for i := range splitPath {
|
for i := range splitPath {
|
||||||
@ -70,7 +70,7 @@ func BuildTreeFromCommitFiles(files []*models.CommitFile) *Node[models.CommitFil
|
|||||||
|
|
||||||
var curr *Node[models.CommitFile]
|
var curr *Node[models.CommitFile]
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
splitPath := split(file.Name)
|
splitPath := split(file.Path)
|
||||||
curr = root
|
curr = root
|
||||||
outer:
|
outer:
|
||||||
for i := range splitPath {
|
for i := range splitPath {
|
||||||
|
@ -25,10 +25,10 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
name: "files in same directory",
|
name: "files in same directory",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir1/b",
|
Path: "dir1/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
@ -38,11 +38,11 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
Path: "dir1",
|
Path: "dir1",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir1/a"},
|
File: &models.File{Path: "dir1/a"},
|
||||||
Path: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir1/b"},
|
File: &models.File{Path: "dir1/b"},
|
||||||
Path: "dir1/b",
|
Path: "dir1/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -54,10 +54,10 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
name: "paths that can be compressed",
|
name: "paths that can be compressed",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "dir1/dir3/a",
|
Path: "dir1/dir3/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir2/dir4/b",
|
Path: "dir2/dir4/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
@ -67,7 +67,7 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
Path: "dir1/dir3",
|
Path: "dir1/dir3",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir1/dir3/a"},
|
File: &models.File{Path: "dir1/dir3/a"},
|
||||||
Path: "dir1/dir3/a",
|
Path: "dir1/dir3/a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -77,7 +77,7 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
Path: "dir2/dir4",
|
Path: "dir2/dir4",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir2/dir4/b"},
|
File: &models.File{Path: "dir2/dir4/b"},
|
||||||
Path: "dir2/dir4/b",
|
Path: "dir2/dir4/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -90,21 +90,21 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
name: "paths that can be sorted",
|
name: "paths that can be sorted",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "a"},
|
File: &models.File{Path: "a"},
|
||||||
Path: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "b"},
|
File: &models.File{Path: "b"},
|
||||||
Path: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -114,14 +114,14 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
name: "paths that can be sorted including a merge conflict file",
|
name: "paths that can be sorted including a merge conflict file",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "z",
|
Path: "z",
|
||||||
HasMergeConflicts: true,
|
HasMergeConflicts: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
@ -130,15 +130,15 @@ func TestBuildTreeFromFiles(t *testing.T) {
|
|||||||
// here but we are technically still in tree mode and that's the rule
|
// here but we are technically still in tree mode and that's the rule
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "a"},
|
File: &models.File{Path: "a"},
|
||||||
Path: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "b"},
|
File: &models.File{Path: "b"},
|
||||||
Path: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "z", HasMergeConflicts: true},
|
File: &models.File{Path: "z", HasMergeConflicts: true},
|
||||||
Path: "z",
|
Path: "z",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -172,22 +172,22 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
|
|||||||
name: "files in same directory",
|
name: "files in same directory",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir1/b",
|
Path: "dir1/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir1/a"},
|
File: &models.File{Path: "dir1/a"},
|
||||||
Path: "dir1/a",
|
Path: "dir1/a",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir1/b"},
|
File: &models.File{Path: "dir1/b"},
|
||||||
Path: "dir1/b",
|
Path: "dir1/b",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
@ -198,22 +198,22 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
|
|||||||
name: "paths that can be compressed",
|
name: "paths that can be compressed",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir2/b",
|
Path: "dir2/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir1/a"},
|
File: &models.File{Path: "dir1/a"},
|
||||||
Path: "dir1/a",
|
Path: "dir1/a",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "dir2/b"},
|
File: &models.File{Path: "dir2/b"},
|
||||||
Path: "dir2/b",
|
Path: "dir2/b",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
@ -224,21 +224,21 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
|
|||||||
name: "paths that can be sorted",
|
name: "paths that can be sorted",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "a"},
|
File: &models.File{Path: "a"},
|
||||||
Path: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "b"},
|
File: &models.File{Path: "b"},
|
||||||
Path: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -248,27 +248,27 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
|
|||||||
name: "tracked, untracked, and conflicted files",
|
name: "tracked, untracked, and conflicted files",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{
|
{
|
||||||
Name: "a2",
|
Path: "a2",
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "a1",
|
Path: "a1",
|
||||||
Tracked: false,
|
Tracked: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "c2",
|
Path: "c2",
|
||||||
HasMergeConflicts: true,
|
HasMergeConflicts: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "c1",
|
Path: "c1",
|
||||||
HasMergeConflicts: true,
|
HasMergeConflicts: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "b2",
|
Path: "b2",
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "b1",
|
Path: "b1",
|
||||||
Tracked: true,
|
Tracked: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -276,27 +276,27 @@ func TestBuildFlatTreeFromFiles(t *testing.T) {
|
|||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "c1", HasMergeConflicts: true},
|
File: &models.File{Path: "c1", HasMergeConflicts: true},
|
||||||
Path: "c1",
|
Path: "c1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "c2", HasMergeConflicts: true},
|
File: &models.File{Path: "c2", HasMergeConflicts: true},
|
||||||
Path: "c2",
|
Path: "c2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "b1", Tracked: true},
|
File: &models.File{Path: "b1", Tracked: true},
|
||||||
Path: "b1",
|
Path: "b1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "b2", Tracked: true},
|
File: &models.File{Path: "b2", Tracked: true},
|
||||||
Path: "b2",
|
Path: "b2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "a1", Tracked: false},
|
File: &models.File{Path: "a1", Tracked: false},
|
||||||
Path: "a1",
|
Path: "a1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "a2", Tracked: false},
|
File: &models.File{Path: "a2", Tracked: false},
|
||||||
Path: "a2",
|
Path: "a2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -330,10 +330,10 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
|
|||||||
name: "files in same directory",
|
name: "files in same directory",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir1/b",
|
Path: "dir1/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.CommitFile]{
|
expected: &Node[models.CommitFile]{
|
||||||
@ -343,11 +343,11 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
|
|||||||
Path: "dir1",
|
Path: "dir1",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir1/a"},
|
File: &models.CommitFile{Path: "dir1/a"},
|
||||||
Path: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir1/b"},
|
File: &models.CommitFile{Path: "dir1/b"},
|
||||||
Path: "dir1/b",
|
Path: "dir1/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -359,10 +359,10 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
|
|||||||
name: "paths that can be compressed",
|
name: "paths that can be compressed",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "dir1/dir3/a",
|
Path: "dir1/dir3/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir2/dir4/b",
|
Path: "dir2/dir4/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.CommitFile]{
|
expected: &Node[models.CommitFile]{
|
||||||
@ -372,7 +372,7 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
|
|||||||
Path: "dir1/dir3",
|
Path: "dir1/dir3",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir1/dir3/a"},
|
File: &models.CommitFile{Path: "dir1/dir3/a"},
|
||||||
Path: "dir1/dir3/a",
|
Path: "dir1/dir3/a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -382,7 +382,7 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
|
|||||||
Path: "dir2/dir4",
|
Path: "dir2/dir4",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir2/dir4/b"},
|
File: &models.CommitFile{Path: "dir2/dir4/b"},
|
||||||
Path: "dir2/dir4/b",
|
Path: "dir2/dir4/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -395,21 +395,21 @@ func TestBuildTreeFromCommitFiles(t *testing.T) {
|
|||||||
name: "paths that can be sorted",
|
name: "paths that can be sorted",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.CommitFile]{
|
expected: &Node[models.CommitFile]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "a"},
|
File: &models.CommitFile{Path: "a"},
|
||||||
Path: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "b"},
|
File: &models.CommitFile{Path: "b"},
|
||||||
Path: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -443,22 +443,22 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
|
|||||||
name: "files in same directory",
|
name: "files in same directory",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir1/b",
|
Path: "dir1/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.CommitFile]{
|
expected: &Node[models.CommitFile]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir1/a"},
|
File: &models.CommitFile{Path: "dir1/a"},
|
||||||
Path: "dir1/a",
|
Path: "dir1/a",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir1/b"},
|
File: &models.CommitFile{Path: "dir1/b"},
|
||||||
Path: "dir1/b",
|
Path: "dir1/b",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
@ -469,22 +469,22 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
|
|||||||
name: "paths that can be compressed",
|
name: "paths that can be compressed",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "dir1/a",
|
Path: "dir1/a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "dir2/b",
|
Path: "dir2/b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.CommitFile]{
|
expected: &Node[models.CommitFile]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir1/a"},
|
File: &models.CommitFile{Path: "dir1/a"},
|
||||||
Path: "dir1/a",
|
Path: "dir1/a",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "dir2/b"},
|
File: &models.CommitFile{Path: "dir2/b"},
|
||||||
Path: "dir2/b",
|
Path: "dir2/b",
|
||||||
CompressionLevel: 0,
|
CompressionLevel: 0,
|
||||||
},
|
},
|
||||||
@ -495,21 +495,21 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) {
|
|||||||
name: "paths that can be sorted",
|
name: "paths that can be sorted",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{
|
{
|
||||||
Name: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.CommitFile]{
|
expected: &Node[models.CommitFile]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.CommitFile]{
|
Children: []*Node[models.CommitFile]{
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "a"},
|
File: &models.CommitFile{Path: "a"},
|
||||||
Path: "a",
|
Path: "a",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.CommitFile{Name: "b"},
|
File: &models.CommitFile{Path: "b"},
|
||||||
Path: "b",
|
Path: "b",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -119,7 +119,7 @@ func (self *CommitFileTree) CollapsedPaths() *CollapsedPaths {
|
|||||||
|
|
||||||
func (self *CommitFileTree) GetFile(path string) *models.CommitFile {
|
func (self *CommitFileTree) GetFile(path string) *models.CommitFile {
|
||||||
for _, file := range self.getFiles() {
|
for _, file := range self.getFiles() {
|
||||||
if file.Name == path {
|
if file.Path == path {
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ func (self *FileNode) GetHasInlineMergeConflicts() bool {
|
|||||||
if !file.HasInlineMergeConflicts {
|
if !file.HasInlineMergeConflicts {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
hasConflicts, _ := mergeconflicts.FileHasConflictMarkers(file.Name)
|
hasConflicts, _ := mergeconflicts.FileHasConflictMarkers(file.Path)
|
||||||
return hasConflicts
|
return hasConflicts
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -69,5 +69,5 @@ func (self *FileNode) GetPreviousPath() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.File.PreviousName
|
return self.File.PreviousPath
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ func TestCompress(t *testing.T) {
|
|||||||
root: &Node[models.File]{
|
root: &Node[models.File]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{File: &models.File{Name: "test", ShortStatus: " M", HasStagedChanges: true}, Path: "test"},
|
{File: &models.File{Path: "test", ShortStatus: " M", HasStagedChanges: true}, Path: "test"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: &Node[models.File]{
|
expected: &Node[models.File]{
|
||||||
Path: "",
|
Path: "",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{File: &models.File{Name: "test", ShortStatus: " M", HasStagedChanges: true}, Path: "test"},
|
{File: &models.File{Path: "test", ShortStatus: " M", HasStagedChanges: true}, Path: "test"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -42,7 +42,7 @@ func TestCompress(t *testing.T) {
|
|||||||
Path: "dir1",
|
Path: "dir1",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file2", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file2", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "dir1/file2",
|
Path: "dir1/file2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -51,11 +51,11 @@ func TestCompress(t *testing.T) {
|
|||||||
Path: "dir2",
|
Path: "dir2",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file3", ShortStatus: " M", HasStagedChanges: true},
|
File: &models.File{Path: "file3", ShortStatus: " M", HasStagedChanges: true},
|
||||||
Path: "dir2/file3",
|
Path: "dir2/file3",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "dir2/file4",
|
Path: "dir2/file4",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -67,7 +67,7 @@ func TestCompress(t *testing.T) {
|
|||||||
Path: "dir3/dir3-1",
|
Path: "dir3/dir3-1",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "dir3/dir3-1/file5",
|
Path: "dir3/dir3-1/file5",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -75,7 +75,7 @@ func TestCompress(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "file1",
|
Path: "file1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -87,7 +87,7 @@ func TestCompress(t *testing.T) {
|
|||||||
Path: "dir1",
|
Path: "dir1",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file2", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file2", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "dir1/file2",
|
Path: "dir1/file2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -96,11 +96,11 @@ func TestCompress(t *testing.T) {
|
|||||||
Path: "dir2",
|
Path: "dir2",
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file3", ShortStatus: " M", HasStagedChanges: true},
|
File: &models.File{Path: "file3", ShortStatus: " M", HasStagedChanges: true},
|
||||||
Path: "dir2/file3",
|
Path: "dir2/file3",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "dir2/file4",
|
Path: "dir2/file4",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -110,13 +110,13 @@ func TestCompress(t *testing.T) {
|
|||||||
CompressionLevel: 1,
|
CompressionLevel: 1,
|
||||||
Children: []*Node[models.File]{
|
Children: []*Node[models.File]{
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "dir3/dir3-1/file5",
|
Path: "dir3/dir3-1/file5",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
File: &models.File{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &models.File{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Path: "file1",
|
Path: "file1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -141,13 +141,13 @@ func TestGetFile(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "valid case",
|
name: "valid case",
|
||||||
viewModel: NewFileTree(func() []*models.File { return []*models.File{{Name: "blah/one"}, {Name: "blah/two"}} }, nil, false),
|
viewModel: NewFileTree(func() []*models.File { return []*models.File{{Path: "blah/one"}, {Path: "blah/two"}} }, nil, false),
|
||||||
path: "blah/two",
|
path: "blah/two",
|
||||||
expected: &models.File{Name: "blah/two"},
|
expected: &models.File{Path: "blah/two"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "not found",
|
name: "not found",
|
||||||
viewModel: NewFileTree(func() []*models.File { return []*models.File{{Name: "blah/one"}, {Name: "blah/two"}} }, nil, false),
|
viewModel: NewFileTree(func() []*models.File { return []*models.File{{Path: "blah/one"}, {Path: "blah/two"}} }, nil, false),
|
||||||
path: "blah/three",
|
path: "blah/three",
|
||||||
expected: nil,
|
expected: nil,
|
||||||
},
|
},
|
||||||
|
@ -125,7 +125,7 @@ func (self *FileTree) Get(index int) *FileNode {
|
|||||||
|
|
||||||
func (self *FileTree) GetFile(path string) *models.File {
|
func (self *FileTree) GetFile(path string) *models.File {
|
||||||
for _, file := range self.getFiles() {
|
for _, file := range self.getFiles() {
|
||||||
if file.Name == path {
|
if file.Path == path {
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,67 +18,67 @@ func TestFilterAction(t *testing.T) {
|
|||||||
name: "filter files with unstaged changes",
|
name: "filter files with unstaged changes",
|
||||||
filter: DisplayUnstaged,
|
filter: DisplayUnstaged,
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", HasStagedChanges: true},
|
{Path: "dir2/file5", ShortStatus: "M ", HasStagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
},
|
},
|
||||||
expected: []*models.File{
|
expected: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "filter files with staged changes",
|
name: "filter files with staged changes",
|
||||||
filter: DisplayStaged,
|
filter: DisplayStaged,
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasStagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasStagedChanges: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", HasStagedChanges: false},
|
{Path: "dir2/file5", ShortStatus: "M ", HasStagedChanges: false},
|
||||||
{Name: "file1", ShortStatus: "M ", HasStagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasStagedChanges: true},
|
||||||
},
|
},
|
||||||
expected: []*models.File{
|
expected: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasStagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasStagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "M ", HasStagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasStagedChanges: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "filter files that are tracked",
|
name: "filter files that are tracked",
|
||||||
filter: DisplayTracked,
|
filter: DisplayTracked,
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", Tracked: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", Tracked: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", Tracked: false},
|
{Path: "dir2/file5", ShortStatus: "M ", Tracked: false},
|
||||||
{Name: "file1", ShortStatus: "M ", Tracked: true},
|
{Path: "file1", ShortStatus: "M ", Tracked: true},
|
||||||
},
|
},
|
||||||
expected: []*models.File{
|
expected: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", Tracked: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", Tracked: true},
|
||||||
{Name: "file1", ShortStatus: "M ", Tracked: true},
|
{Path: "file1", ShortStatus: "M ", Tracked: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "filter all files",
|
name: "filter all files",
|
||||||
filter: DisplayAll,
|
filter: DisplayAll,
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
},
|
},
|
||||||
expected: []*models.File{
|
expected: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "filter conflicted files",
|
name: "filter conflicted files",
|
||||||
filter: DisplayConflicted,
|
filter: DisplayConflicted,
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "DU", HasMergeConflicts: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "DU", HasMergeConflicts: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir2/file6", ShortStatus: " M", HasStagedChanges: true},
|
{Path: "dir2/file6", ShortStatus: " M", HasStagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "UU", HasMergeConflicts: true, HasInlineMergeConflicts: true},
|
{Path: "file1", ShortStatus: "UU", HasMergeConflicts: true, HasInlineMergeConflicts: true},
|
||||||
},
|
},
|
||||||
expected: []*models.File{
|
expected: []*models.File{
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "DU", HasMergeConflicts: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "DU", HasMergeConflicts: true},
|
||||||
{Name: "file1", ShortStatus: "UU", HasMergeConflicts: true, HasInlineMergeConflicts: true},
|
{Path: "file1", ShortStatus: "UU", HasMergeConflicts: true, HasInlineMergeConflicts: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,8 @@ func (self *FileTreeViewModel) SetTree() {
|
|||||||
|
|
||||||
// for when you stage the old file of a rename and the new file is in a collapsed dir
|
// for when you stage the old file of a rename and the new file is in a collapsed dir
|
||||||
for _, file := range newFiles {
|
for _, file := range newFiles {
|
||||||
if selectedNode != nil && selectedNode.Path != "" && file.PreviousName == selectedNode.Path {
|
if selectedNode != nil && selectedNode.Path != "" && file.PreviousPath == selectedNode.Path {
|
||||||
self.ExpandToPath(file.Name)
|
self.ExpandToPath(file.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ func (self *FileTreeViewModel) findNewSelectedIdx(prevNodes []*FileNode, currNod
|
|||||||
|
|
||||||
// If you started off with a rename selected, and now it's broken in two, we want you to jump to the new file, not the old file.
|
// If you started off with a rename selected, and now it's broken in two, we want you to jump to the new file, not the old file.
|
||||||
// This is because the new should be in the same position as the rename was meaning less cursor jumping
|
// This is because the new should be in the same position as the rename was meaning less cursor jumping
|
||||||
foundOldFileInRename := prevNode.File != nil && prevNode.File.IsRename() && node.Path == prevNode.File.PreviousName
|
foundOldFileInRename := prevNode.File != nil && prevNode.File.IsRename() && node.Path == prevNode.File.PreviousPath
|
||||||
foundNode := utils.StringArraysOverlap(paths, selectedPaths) && !foundOldFileInRename
|
foundNode := utils.StringArraysOverlap(paths, selectedPaths) && !foundOldFileInRename
|
||||||
if foundNode {
|
if foundNode {
|
||||||
return idx
|
return idx
|
||||||
|
@ -52,11 +52,11 @@ func commitFilePatchStatus(node *filetree.Node[models.CommitFile], tree *filetre
|
|||||||
// be whatever status it is, but if it's a non-leaf it will determine its status
|
// be whatever status it is, but if it's a non-leaf it will determine its status
|
||||||
// based on the leaves of that subtree
|
// based on the leaves of that subtree
|
||||||
if node.EveryFile(func(file *models.CommitFile) bool {
|
if node.EveryFile(func(file *models.CommitFile) bool {
|
||||||
return patchBuilder.GetFileStatus(file.Name, tree.GetRef().RefName()) == patch.WHOLE
|
return patchBuilder.GetFileStatus(file.Path, tree.GetRef().RefName()) == patch.WHOLE
|
||||||
}) {
|
}) {
|
||||||
return patch.WHOLE
|
return patch.WHOLE
|
||||||
} else if node.EveryFile(func(file *models.CommitFile) bool {
|
} else if node.EveryFile(func(file *models.CommitFile) bool {
|
||||||
return patchBuilder.GetFileStatus(file.Name, tree.GetRef().RefName()) == patch.UNSELECTED
|
return patchBuilder.GetFileStatus(file.Path, tree.GetRef().RefName()) == patch.UNSELECTED
|
||||||
}) {
|
}) {
|
||||||
return patch.UNSELECTED
|
return patch.UNSELECTED
|
||||||
} else {
|
} else {
|
||||||
@ -297,9 +297,9 @@ func fileNameAtDepth(node *filetree.Node[models.File], depth int) string {
|
|||||||
name := join(splitName[depth:])
|
name := join(splitName[depth:])
|
||||||
|
|
||||||
if node.File != nil && node.File.IsRename() {
|
if node.File != nil && node.File.IsRename() {
|
||||||
splitPrevName := split(node.File.PreviousName)
|
splitPrevName := split(node.File.PreviousPath)
|
||||||
|
|
||||||
prevName := node.File.PreviousName
|
prevName := node.File.PreviousPath
|
||||||
// if the file has just been renamed inside the same directory, we can shave off
|
// if the file has just been renamed inside the same directory, we can shave off
|
||||||
// the prefix for the previous path too. Otherwise we'll keep it unchanged
|
// the prefix for the previous path too. Otherwise we'll keep it unchanged
|
||||||
sameParentDir := len(splitName) == len(splitPrevName) && join(splitName[0:depth]) == join(splitPrevName[0:depth])
|
sameParentDir := len(splitName) == len(splitPrevName) && join(splitName[0:depth]) == join(splitPrevName[0:depth])
|
||||||
|
@ -34,17 +34,17 @@ func TestRenderFileTree(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "leaf node",
|
name: "leaf node",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "test", ShortStatus: " M", HasStagedChanges: true},
|
{Path: "test", ShortStatus: " M", HasStagedChanges: true},
|
||||||
},
|
},
|
||||||
expected: []string{" M test"},
|
expected: []string{" M test"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "numstat",
|
name: "numstat",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "test", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 1, LinesDeleted: 1},
|
{Path: "test", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 1, LinesDeleted: 1},
|
||||||
{Name: "test2", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 1},
|
{Path: "test2", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 1},
|
||||||
{Name: "test3", ShortStatus: " M", HasStagedChanges: true, LinesDeleted: 1},
|
{Path: "test3", ShortStatus: " M", HasStagedChanges: true, LinesDeleted: 1},
|
||||||
{Name: "test4", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 0, LinesDeleted: 0},
|
{Path: "test4", ShortStatus: " M", HasStagedChanges: true, LinesAdded: 0, LinesDeleted: 0},
|
||||||
},
|
},
|
||||||
showLineChanges: true,
|
showLineChanges: true,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -57,12 +57,12 @@ func TestRenderFileTree(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "big example",
|
name: "big example",
|
||||||
files: []*models.File{
|
files: []*models.File{
|
||||||
{Name: "dir1/file2", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir1/file2", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir1/file3", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir1/file3", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir2/dir2/file3", ShortStatus: " M", HasStagedChanges: true},
|
{Path: "dir2/dir2/file3", ShortStatus: " M", HasStagedChanges: true},
|
||||||
{Name: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/dir2/file4", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "dir2/file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
{Path: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
},
|
},
|
||||||
expected: toStringSlice(
|
expected: toStringSlice(
|
||||||
`
|
`
|
||||||
@ -111,19 +111,19 @@ func TestRenderCommitFileTree(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "leaf node",
|
name: "leaf node",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{Name: "test", ChangeStatus: "A"},
|
{Path: "test", ChangeStatus: "A"},
|
||||||
},
|
},
|
||||||
expected: []string{"A test"},
|
expected: []string{"A test"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "big example",
|
name: "big example",
|
||||||
files: []*models.CommitFile{
|
files: []*models.CommitFile{
|
||||||
{Name: "dir1/file2", ChangeStatus: "M"},
|
{Path: "dir1/file2", ChangeStatus: "M"},
|
||||||
{Name: "dir1/file3", ChangeStatus: "A"},
|
{Path: "dir1/file3", ChangeStatus: "A"},
|
||||||
{Name: "dir2/dir2/file3", ChangeStatus: "D"},
|
{Path: "dir2/dir2/file3", ChangeStatus: "D"},
|
||||||
{Name: "dir2/dir2/file4", ChangeStatus: "M"},
|
{Path: "dir2/dir2/file4", ChangeStatus: "M"},
|
||||||
{Name: "dir2/file5", ChangeStatus: "M"},
|
{Path: "dir2/file5", ChangeStatus: "M"},
|
||||||
{Name: "file1", ChangeStatus: "M"},
|
{Path: "file1", ChangeStatus: "M"},
|
||||||
},
|
},
|
||||||
expected: toStringSlice(
|
expected: toStringSlice(
|
||||||
`
|
`
|
||||||
|
@ -47,8 +47,8 @@ func fileShimFromModelFile(file *models.File) *File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &File{
|
return &File{
|
||||||
Name: file.Name,
|
Name: file.Path,
|
||||||
PreviousName: file.PreviousName,
|
PreviousName: file.PreviousPath,
|
||||||
HasStagedChanges: file.HasStagedChanges,
|
HasStagedChanges: file.HasStagedChanges,
|
||||||
HasUnstagedChanges: file.HasUnstagedChanges,
|
HasUnstagedChanges: file.HasUnstagedChanges,
|
||||||
Tracked: file.Tracked,
|
Tracked: file.Tracked,
|
||||||
@ -141,7 +141,7 @@ func commitFileShimFromModelRemote(commitFile *models.CommitFile) *CommitFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &CommitFile{
|
return &CommitFile{
|
||||||
Name: commitFile.Name,
|
Name: commitFile.Path,
|
||||||
ChangeStatus: commitFile.ChangeStatus,
|
ChangeStatus: commitFile.ChangeStatus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user