-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhistorymodel.go
49 lines (39 loc) · 1.26 KB
/
historymodel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package git
import (
"time"
"github.com/samber/lo"
"projectforge.dev/projectforge/app/util"
)
type HistoryResult struct {
Path string `json:"path,omitempty"`
Since *time.Time `json:"since,omitempty"`
Authors []string `json:"authors,omitempty"`
Limit int `json:"limit,omitempty"`
Commit string `json:"commit,omitempty"`
Entries HistoryEntries `json:"entries"`
Debug any `json:"debug,omitempty"`
}
type HistoryEntry struct {
Headers util.ValueMap `json:"headers" xml:"headers"`
SHA string `json:"sha" xml:"sha"`
AuthorName string `json:"authorName" xml:"authorName"`
AuthorEmail string `json:"authorEmail" xml:"authorEmail"`
Message string `json:"message" xml:"message"`
Occurred string `json:"occurred" xml:"occurred"`
Files HistoryFiles `json:"files" xml:"files"`
}
func (h *HistoryEntry) OccurredTime() *time.Time {
ret, _ := util.TimeFromVerbose(h.Occurred)
return ret
}
type HistoryEntries []*HistoryEntry
func (h HistoryEntries) Get(sha string) *HistoryEntry {
return lo.FindOrElse(h, nil, func(x *HistoryEntry) bool {
return x.SHA == sha
})
}
type HistoryFile struct {
Status string
File string
}
type HistoryFiles []*HistoryFile