godox

Ayman Bagabas created

Change summary

ui/pages/repo/log.go       | 12 ++++++++++++
ui/pages/repo/logitem.go   | 17 +++++++++++++++--
ui/pages/selection/item.go |  1 +
3 files changed, 28 insertions(+), 2 deletions(-)

Detailed changes

ui/pages/repo/log.go 🔗

@@ -27,14 +27,19 @@ const (
 	commitView
 )
 
+// LogCountMsg is a message that contains the number of commits in a repo.
 type LogCountMsg int64
 
+// LogItemsMsg is a message that contains a slice of LogItem.
 type LogItemsMsg []list.Item
 
+// LogCommitMsg is a message that contains a git commit.
 type LogCommitMsg *ggit.Commit
 
+// LogDiffMsg is a message that contains a git diff.
 type LogDiffMsg *ggit.Diff
 
+// Log is a model that displays a list of commits and their diffs.
 type Log struct {
 	common         common.Common
 	selector       *selector.Selector
@@ -48,6 +53,7 @@ type Log struct {
 	currentDiff    *ggit.Diff
 }
 
+// NewLog creates a new Log model.
 func NewLog(common common.Common) *Log {
 	l := &Log{
 		common:     common,
@@ -68,12 +74,14 @@ func NewLog(common common.Common) *Log {
 	return l
 }
 
+// SetSize implements common.Component.
 func (l *Log) SetSize(width, height int) {
 	l.common.SetSize(width, height)
 	l.selector.SetSize(width, height)
 	l.vp.SetSize(width, height)
 }
 
+// ShortHelp implements key.KeyMap.
 func (l *Log) ShortHelp() []key.Binding {
 	switch l.activeView {
 	case logView:
@@ -108,12 +116,14 @@ func (l *Log) ShortHelp() []key.Binding {
 	}
 }
 
+// Init implements tea.Model.
 func (l *Log) Init() tea.Cmd {
 	cmds := make([]tea.Cmd, 0)
 	cmds = append(cmds, l.updateCommitsCmd)
 	return tea.Batch(cmds...)
 }
 
+// Update implements tea.Model.
 func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	cmds := make([]tea.Cmd, 0)
 	switch msg := msg.(type) {
@@ -208,6 +218,7 @@ func (l *Log) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	return l, tea.Batch(cmds...)
 }
 
+// View implements tea.Model.
 func (l *Log) View() string {
 	switch l.activeView {
 	case logView:
@@ -219,6 +230,7 @@ func (l *Log) View() string {
 	}
 }
 
+// StatusBarInfo returns the status bar info.
 func (l *Log) StatusBarInfo() string {
 	switch l.activeView {
 	case logView:

ui/pages/repo/logitem.go 🔗

@@ -12,14 +12,17 @@ import (
 	"github.com/muesli/reflow/truncate"
 )
 
+// LogItem is a item in the log list that displays a git commit.
 type LogItem struct {
 	*git.Commit
 }
 
+// ID implements selector.IdentifiableItem.
 func (i LogItem) ID() string {
 	return i.Commit.ID.String()
 }
 
+// Title returns the item title. Implements list.DefaultItem.
 func (i LogItem) Title() string {
 	if i.Commit != nil {
 		return strings.Split(i.Commit.Message, "\n")[0]
@@ -27,17 +30,27 @@ func (i LogItem) Title() string {
 	return ""
 }
 
+// Description returns the item description. Implements list.DefaultItem.
 func (i LogItem) Description() string { return "" }
 
+// FilterValue implements list.Item.
 func (i LogItem) FilterValue() string { return i.Title() }
 
+// LogItemDelegate is the delegate for LogItem.
 type LogItemDelegate struct {
 	style *styles.Styles
 }
 
-func (d LogItemDelegate) Height() int                               { return 1 }
-func (d LogItemDelegate) Spacing() int                              { return 0 }
+// Height returns the item height. Implements list.ItemDelegate.
+func (d LogItemDelegate) Height() int { return 1 }
+
+// Spacing returns the item spacing. Implements list.ItemDelegate.
+func (d LogItemDelegate) Spacing() int { return 0 }
+
+// Update updates the item. Implements list.ItemDelegate.
 func (d LogItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { return nil }
+
+// Render renders the item. Implements list.ItemDelegate.
 func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
 	i, ok := listItem.(LogItem)
 	if !ok {

ui/pages/selection/item.go 🔗

@@ -37,6 +37,7 @@ func (i Item) Description() string { return i.desc }
 // FilterValue implements list.Item.
 func (i Item) FilterValue() string { return i.name }
 
+// URL returns the item URL view.
 func (i Item) URL() string {
 	return i.url.View()
 }