Detailed changes
@@ -160,7 +160,7 @@ func (b Bubble) footerView() string {
var h []gittypes.HelpEntry
if b.state != errorState {
h = []gittypes.HelpEntry{
- {"tab", "section"},
+ {Key: "tab", Value: "section"},
}
if box, ok := b.boxes[b.activeBox].(gittypes.BubbleHelper); ok {
help := box.Help()
@@ -169,7 +169,7 @@ func (b Bubble) footerView() string {
}
}
}
- h = append(h, gittypes.HelpEntry{"q", "quit"})
+ h = append(h, gittypes.HelpEntry{Key: "q", Value: "quit"})
for i, v := range h {
fmt.Fprint(w, helpEntryRender(v, b.styles))
if i != len(h)-1 {
@@ -110,10 +110,10 @@ func (b *Bubble) Help() []types.HelpEntry {
h := []types.HelpEntry{}
h = append(h, b.boxes[b.state].(types.BubbleHelper).Help()...)
if b.repo.Name() != "config" {
- h = append(h, types.HelpEntry{"R", "readme"})
- h = append(h, types.HelpEntry{"F", "files"})
- h = append(h, types.HelpEntry{"C", "commits"})
- h = append(h, types.HelpEntry{"B", "branches"})
+ h = append(h, types.HelpEntry{Key: "R", Value: "readme"})
+ h = append(h, types.HelpEntry{Key: "F", Value: "files"})
+ h = append(h, types.HelpEntry{Key: "C", Value: "commits"})
+ h = append(h, types.HelpEntry{Key: "B", Value: "branches"})
}
return h
}
@@ -45,7 +45,7 @@ const (
)
type item struct {
- *types.Commit
+ *object.Commit
}
func (i item) Title() string {
@@ -229,28 +229,28 @@ func (b *Bubble) loadCommit() tea.Cmd {
// https://github.com/go-git/go-git/issues/281
tree, err := c.Tree()
if err != nil {
- return types.ErrMsg{err}
+ return types.ErrMsg{Err: err}
}
var parent *object.Commit
parentTree := &object.Tree{}
if c.NumParents() > 0 {
parent, err = c.Parents().Next()
if err != nil {
- return types.ErrMsg{err}
+ return types.ErrMsg{Err: err}
}
parentTree, err = parent.Tree()
if err != nil {
- return types.ErrMsg{err}
+ return types.ErrMsg{Err: err}
}
}
ctx, cancel := context.WithTimeout(context.TODO(), types.MaxPatchWait)
defer cancel()
patch, err := parentTree.PatchContext(ctx, tree)
if err != nil {
- return types.ErrMsg{err}
+ return types.ErrMsg{Err: err}
}
return commitMsg{
- commit: c.Commit.Commit,
+ commit: c.Commit,
tree: tree,
parent: parent,
parentTree: parentTree,
@@ -187,7 +187,7 @@ func (b *Bubble) updateItems() tea.Cmd {
its := make(items, 0)
t, err := b.repo.Tree(b.ref, b.path)
if err != nil {
- return func() tea.Msg { return types.ErrMsg{err} }
+ return func() tea.Msg { return types.ErrMsg{Err: err} }
}
tw := object.NewTreeWalker(t, false, map[plumbing.Hash]bool{})
defer tw.Close()
@@ -307,18 +307,18 @@ func (b *Bubble) View() string {
func (b *Bubble) loadFile(i item) tea.Cmd {
return func() tea.Msg {
if !i.Mode().IsFile() || i.file == nil {
- return types.ErrMsg{types.ErrInvalidFile}
+ return types.ErrMsg{Err: types.ErrInvalidFile}
}
bin, err := i.file.IsBinary()
if err != nil {
- return types.ErrMsg{err}
+ return types.ErrMsg{Err: err}
}
if bin {
- return types.ErrMsg{types.ErrBinaryFile}
+ return types.ErrMsg{Err: types.ErrBinaryFile}
}
c, err := i.file.Contents()
if err != nil {
- return types.ErrMsg{err}
+ return types.ErrMsg{Err: err}
}
return fileMsg{
content: c,
@@ -17,11 +17,7 @@ type Repo interface {
Tree(*plumbing.Reference, string) (*object.Tree, error)
}
-type Commit struct {
- *object.Commit
-}
-
-type Commits []*Commit
+type Commits []*object.Commit
func (cl Commits) Len() int { return len(cl) }
func (cl Commits) Swap(i, j int) { cl[i], cl[j] = cl[j], cl[i] }
@@ -82,7 +82,7 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (b *Bubble) Help() []gittypes.HelpEntry {
return []gittypes.HelpEntry{
- {"↑/↓", "navigate"},
+ {Key: "↑/↓", Value: "navigate"},
}
}