mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-19 12:12:42 +02:00
commands/git : remove includes function
This commit is contained in:
parent
56ad07ebab
commit
a0faaf6893
@ -123,15 +123,6 @@ func (c *GitCommand) GetStashEntryDiff(index int) (string, error) {
|
|||||||
return c.OSCommand.RunCommandWithOutput("git stash show -p --color stash@{" + fmt.Sprint(index) + "}")
|
return c.OSCommand.RunCommandWithOutput("git stash show -p --color stash@{" + fmt.Sprint(index) + "}")
|
||||||
}
|
}
|
||||||
|
|
||||||
func includes(array []string, str string) bool {
|
|
||||||
for _, arrayStr := range array {
|
|
||||||
if arrayStr == str {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetStatusFiles git status files
|
// GetStatusFiles git status files
|
||||||
func (c *GitCommand) GetStatusFiles() []File {
|
func (c *GitCommand) GetStatusFiles() []File {
|
||||||
statusOutput, _ := c.GitStatus()
|
statusOutput, _ := c.GitStatus()
|
||||||
@ -143,13 +134,15 @@ func (c *GitCommand) GetStatusFiles() []File {
|
|||||||
stagedChange := change[0:1]
|
stagedChange := change[0:1]
|
||||||
unstagedChange := statusString[1:2]
|
unstagedChange := statusString[1:2]
|
||||||
filename := c.OSCommand.Unquote(statusString[3:])
|
filename := c.OSCommand.Unquote(statusString[3:])
|
||||||
tracked := !includes([]string{"??", "A ", "AM"}, change)
|
_, untracked := map[string]bool{"??": true, "A ": true, "AM": true}[change]
|
||||||
|
_, hasUnstagedChanges := map[string]bool{" ": true, "U": true, "?": true}[stagedChange]
|
||||||
|
|
||||||
file := File{
|
file := File{
|
||||||
Name: filename,
|
Name: filename,
|
||||||
DisplayString: statusString,
|
DisplayString: statusString,
|
||||||
HasStagedChanges: !includes([]string{" ", "U", "?"}, stagedChange),
|
HasStagedChanges: !hasUnstagedChanges,
|
||||||
HasUnstagedChanges: unstagedChange != " ",
|
HasUnstagedChanges: unstagedChange != " ",
|
||||||
Tracked: tracked,
|
Tracked: !untracked,
|
||||||
Deleted: unstagedChange == "D" || stagedChange == "D",
|
Deleted: unstagedChange == "D" || stagedChange == "D",
|
||||||
HasMergeConflicts: change == "UU",
|
HasMergeConflicts: change == "UU",
|
||||||
Type: c.OSCommand.FileType(filename),
|
Type: c.OSCommand.FileType(filename),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user