Skip to content

Commit eef7662

Browse files
committed
use a custom struct for a todo's commit
1 parent bd0139d commit eef7662

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

pkg/todos/todos.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"regexp"
66
"strings"
77
"sync"
8+
"time"
89

910
"github.com/augmentable-dev/tickgit/pkg/comments"
1011
"github.com/dustin/go-humanize"
@@ -17,7 +18,20 @@ import (
1718
type ToDo struct {
1819
comments.Comment
1920
String string
20-
Commit *object.Commit
21+
Commit *Commit
22+
}
23+
24+
// Commit represents the commit a todo originated in
25+
type Commit struct {
26+
Hash string
27+
Author
28+
}
29+
30+
// Author represents the authoring of the commit a todo originated in
31+
type Author struct {
32+
Name string
33+
Email string
34+
When time.Time
2135
}
2236

2337
// ToDos represents a list of ToDo items
@@ -143,7 +157,14 @@ func (t *ToDos) FindBlame(ctx context.Context, repo *git.Repository, from *objec
143157
}
144158
mux.Unlock()
145159
if !exists { // if the todo doesn't exist in this commit, it was added in the previous commit (previous wrt the iterator, more recent in time)
146-
todo.Commit = prevCommit
160+
todo.Commit = &Commit{
161+
Hash: prevCommit.Hash.String(),
162+
Author: Author{
163+
Name: prevCommit.Author.Name,
164+
Email: prevCommit.Author.Email,
165+
When: prevCommit.Author.When,
166+
},
167+
}
147168
} else { // if the todo does exist in this commit, add it to the new list of remaining todos
148169
newRemainingTodos = append(newRemainingTodos, todo)
149170
}

0 commit comments

Comments
 (0)