diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-21 12:18:26 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-25 09:39:04 +1100 |
commit | 98fbc6122150986ebd72bbf18a5a9b262ad932ce (patch) | |
tree | 315d5c5dae3210b4e11d783648b2a44eb2732f3b /pkg/gui/presentation | |
parent | f80d15062b4296c452645b167e76c1a5a13e52fc (diff) |
better formatted reflog list
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/reflog_commits.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/gui/presentation/reflog_commits.go b/pkg/gui/presentation/reflog_commits.go new file mode 100644 index 000000000..9ec325fb3 --- /dev/null +++ b/pkg/gui/presentation/reflog_commits.go @@ -0,0 +1,37 @@ +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" +) + +func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool) [][]string { + lines := make([][]string, len(commits)) + + var displayFunc func(*commands.Commit) []string + if fullDescription { + displayFunc = getFullDescriptionDisplayStringsForReflogCommit + } else { + displayFunc = getDisplayStringsForReflogCommit + } + + for i := range commits { + lines[i] = displayFunc(commits[i]) + } + + return lines +} + +func getFullDescriptionDisplayStringsForReflogCommit(c *commands.Commit) []string { + defaultColor := color.New(theme.DefaultTextColor) + + return []string{utils.ColoredString(c.Sha[:8], color.FgBlue), utils.ColoredString(c.Date, color.FgMagenta), defaultColor.Sprint(c.Name)} +} + +func getDisplayStringsForReflogCommit(c *commands.Commit) []string { + defaultColor := color.New(theme.DefaultTextColor) + + return []string{utils.ColoredString(c.Sha[:8], color.FgBlue), defaultColor.Sprint(c.Name)} +} |