diff options
Diffstat (limited to 'pkg/commands/file.go')
-rw-r--r-- | pkg/commands/file.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pkg/commands/file.go b/pkg/commands/file.go index 754b2871f..4a277be22 100644 --- a/pkg/commands/file.go +++ b/pkg/commands/file.go @@ -1,6 +1,10 @@ package commands -import "strings" +import ( + "strings" + + "github.com/jesseduffield/lazygit/pkg/utils" +) // File : A file from git status // duplicating this for now @@ -17,6 +21,18 @@ type File struct { ShortStatus string // e.g. 'AD', ' A', 'M ', '??' } +const RENAME_SEPARATOR = " -> " + func (f *File) IsRename() bool { - return strings.Contains(f.Name, " -> ") + 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()) } |