|
|
|
@ -22,6 +22,7 @@ type RepoCommits struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CommitNode struct {
|
|
|
|
|
Id string
|
|
|
|
|
Parents map[*CommitNode]Empty
|
|
|
|
|
Children map[*CommitNode]Empty
|
|
|
|
|
Content Commit
|
|
|
|
@ -44,15 +45,23 @@ type Commit struct {
|
|
|
|
|
Version int `json:"version"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func nilable(s *string) string {
|
|
|
|
|
if s == nil {
|
|
|
|
|
return "<nil>"
|
|
|
|
|
} else {
|
|
|
|
|
return *s
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c* Commit) String() string {
|
|
|
|
|
return fmt.Sprintf(`RootId: %s
|
|
|
|
|
CreatorName: %s
|
|
|
|
|
Creator: %s
|
|
|
|
|
Description: %s
|
|
|
|
|
Ctime: %s
|
|
|
|
|
RepoName: %s
|
|
|
|
|
RepoDesc: %s
|
|
|
|
|
`, *c.RootId, *c.CreatorName, *c.Creator, *c.Description, time.Unix(c.Ctime, 0), *c.RepoName, *c.RepoDesc)
|
|
|
|
|
return fmt.Sprintf(`RootId: %v
|
|
|
|
|
CreatorName: %v
|
|
|
|
|
Creator: %v
|
|
|
|
|
Description: %v
|
|
|
|
|
Ctime: %v
|
|
|
|
|
RepoName: %v
|
|
|
|
|
RepoDesc: %v
|
|
|
|
|
`, nilable(c.RootId), nilable(c.CreatorName), nilable(c.Creator), nilable(c.Description), time.Unix(c.Ctime, 0), nilable(c.RepoName), nilable(c.RepoDesc))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewRepoCommits (config configCollect) *RepoCommits {
|
|
|
|
@ -81,9 +90,10 @@ func (rc* RepoCommits) CollectDescs() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewCommitNode(c Commit) *CommitNode {
|
|
|
|
|
func NewCommitNode(c Commit, id string) *CommitNode {
|
|
|
|
|
cn := new(CommitNode)
|
|
|
|
|
cn.Content = c
|
|
|
|
|
cn.Id = id
|
|
|
|
|
cn.Parents = make(map[*CommitNode]Empty)
|
|
|
|
|
cn.Children = make(map[*CommitNode]Empty)
|
|
|
|
|
|
|
|
|
@ -96,8 +106,11 @@ func (rc* RepoCommits) CollectContent() {
|
|
|
|
|
if err != nil { log.Fatal(err) }
|
|
|
|
|
|
|
|
|
|
var c Commit;
|
|
|
|
|
json.Unmarshal(data, &c)
|
|
|
|
|
rc.CommitContent[id] = NewCommitNode(c)
|
|
|
|
|
err := json.Unmarshal(data, &c)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
rc.CommitContent[id] = NewCommitNode(c,id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|