1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/presentation/commit_files.go

48 lines
1.1 KiB
Go
Raw Normal View History

2020-02-25 11:55:36 +02:00
package presentation
import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
2020-08-15 03:18:40 +02:00
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/gui/style"
2020-02-25 11:55:36 +02:00
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
2020-02-25 11:55:36 +02:00
)
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, status patch.PatchStatus) string {
colour := theme.DefaultTextColor
2021-03-31 13:08:55 +02:00
if diffName == name {
colour = theme.DiffTerminalColor
} else {
2021-03-31 13:39:55 +02:00
switch status {
2021-03-31 13:08:55 +02:00
case patch.WHOLE:
colour = style.FgGreen
2021-03-31 13:08:55 +02:00
case patch.PART:
colour = style.FgYellow
2021-03-31 13:08:55 +02:00
}
}
2021-03-31 13:08:55 +02:00
name = utils.EscapeSpecialChars(name)
if commitFile == nil {
return colour.Sprint(name)
}
return getColorForChangeStatus(commitFile.ChangeStatus).Sprint(commitFile.ChangeStatus) + " " + colour.Sprint(name)
}
func getColorForChangeStatus(changeStatus string) style.TextStyle {
switch changeStatus {
case "A":
return style.FgGreen
case "M", "R":
return style.FgYellow
case "D":
return style.FgRed
case "C":
return style.FgCyan
case "T":
return style.FgMagenta
default:
return theme.DefaultTextColor
}
2020-02-25 11:55:36 +02:00
}