2020-03-21 03:18:26 +02:00
|
|
|
package presentation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/fatih/color"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
|
|
)
|
|
|
|
|
2020-03-29 05:34:17 +02:00
|
|
|
func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, diffName string) [][]string {
|
2020-03-21 03:18:26 +02:00
|
|
|
lines := make([][]string, len(commits))
|
|
|
|
|
2020-03-29 05:34:17 +02:00
|
|
|
var displayFunc func(*commands.Commit, bool) []string
|
2020-03-21 03:18:26 +02:00
|
|
|
if fullDescription {
|
|
|
|
displayFunc = getFullDescriptionDisplayStringsForReflogCommit
|
|
|
|
} else {
|
|
|
|
displayFunc = getDisplayStringsForReflogCommit
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := range commits {
|
2020-03-29 05:34:17 +02:00
|
|
|
diffed := commits[i].Sha == diffName
|
|
|
|
lines[i] = displayFunc(commits[i], diffed)
|
2020-03-21 03:18:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return lines
|
|
|
|
}
|
|
|
|
|
2020-03-29 05:34:17 +02:00
|
|
|
func getFullDescriptionDisplayStringsForReflogCommit(c *commands.Commit, diffed bool) []string {
|
|
|
|
colorAttr := theme.DefaultTextColor
|
|
|
|
if diffed {
|
|
|
|
colorAttr = theme.DiffTerminalColor
|
|
|
|
}
|
2020-03-21 03:18:26 +02:00
|
|
|
|
2020-03-27 10:12:15 +02:00
|
|
|
return []string{
|
|
|
|
utils.ColoredString(c.ShortSha(), color.FgBlue),
|
|
|
|
utils.ColoredString(utils.UnixToDate(c.UnixTimestamp), color.FgMagenta),
|
2020-03-29 05:34:17 +02:00
|
|
|
utils.ColoredString(c.Name, colorAttr),
|
2020-03-27 10:12:15 +02:00
|
|
|
}
|
2020-03-21 03:18:26 +02:00
|
|
|
}
|
|
|
|
|
2020-03-29 05:34:17 +02:00
|
|
|
func getDisplayStringsForReflogCommit(c *commands.Commit, diffed bool) []string {
|
2020-03-21 03:18:26 +02:00
|
|
|
defaultColor := color.New(theme.DefaultTextColor)
|
|
|
|
|
2020-03-26 00:18:52 +02:00
|
|
|
return []string{utils.ColoredString(c.ShortSha(), color.FgBlue), defaultColor.Sprint(c.Name)}
|
2020-03-21 03:18:26 +02:00
|
|
|
}
|