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