summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-21 12:18:26 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-25 09:39:04 +1100
commit98fbc6122150986ebd72bbf18a5a9b262ad932ce (patch)
tree315d5c5dae3210b4e11d783648b2a44eb2732f3b /pkg
parentf80d15062b4296c452645b167e76c1a5a13e52fc (diff)
better formatted reflog list
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/presentation/reflog_commits.go37
-rw-r--r--pkg/gui/reflog_panel.go2
2 files changed, 38 insertions, 1 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)}
+}
diff --git a/pkg/gui/reflog_panel.go b/pkg/gui/reflog_panel.go
index fb1aa3978..4bdfddb54 100644
--- a/pkg/gui/reflog_panel.go
+++ b/pkg/gui/reflog_panel.go
@@ -67,7 +67,7 @@ func (gui *Gui) renderReflogCommitsWithSelection() error {
commitsView := gui.getCommitsView()
gui.refreshSelectedLine(&gui.State.Panels.ReflogCommits.SelectedLine, len(gui.State.ReflogCommits))
- displayStrings := presentation.GetCommitListDisplayStrings(gui.State.ReflogCommits, gui.State.ScreenMode != SCREEN_NORMAL)
+ displayStrings := presentation.GetReflogCommitListDisplayStrings(gui.State.ReflogCommits, gui.State.ScreenMode != SCREEN_NORMAL)
gui.renderDisplayStrings(commitsView, displayStrings)
if gui.g.CurrentView() == commitsView && commitsView.Context == "reflog-commits" {
if err := gui.handleReflogCommitSelect(gui.g, commitsView); err != nil {