|
|
@ -16,7 +16,7 @@ type RepoCommits struct { |
|
|
|
Config configCollect |
|
|
|
CommitDesc map[string]string |
|
|
|
CommitContent map[string]*CommitNode |
|
|
|
Root *CommitNode |
|
|
|
Root map[*CommitNode]Empty |
|
|
|
Leafs map[*CommitNode]Empty |
|
|
|
Head *CommitNode |
|
|
|
} |
|
|
@ -60,6 +60,7 @@ func NewRepoCommits (config configCollect) *RepoCommits { |
|
|
|
rc.Config = config |
|
|
|
rc.CommitDesc = make(map[string]string) |
|
|
|
rc.CommitContent = make(map[string]*CommitNode) |
|
|
|
rc.Root = make(map[*CommitNode]Empty) |
|
|
|
rc.Leafs = make(map[*CommitNode]Empty) |
|
|
|
return rc |
|
|
|
} |
|
|
@ -100,14 +101,10 @@ func (rc* RepoCommits) CollectContent() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (rc* RepoCommits) BuildGraph() *CommitNode { |
|
|
|
func (rc* RepoCommits) BuildGraph() map[*CommitNode]Empty { |
|
|
|
for _, cn := range rc.CommitContent { |
|
|
|
if cn.Content.ParentId == nil && cn.Content.SecondParentId == nil { |
|
|
|
if rc.Root == nil { |
|
|
|
rc.Root = cn |
|
|
|
} else { |
|
|
|
log.Fatal("More than one root commit has been found") |
|
|
|
} |
|
|
|
rc.Root[cn] = empty |
|
|
|
} |
|
|
|
|
|
|
|
if cn.Content.ParentId != nil { |
|
|
@ -123,7 +120,7 @@ func (rc* RepoCommits) BuildGraph() *CommitNode { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if rc.Root == nil { |
|
|
|
if len(rc.Root) == 0 { |
|
|
|
log.Fatal("Root commit has not been found") |
|
|
|
} |
|
|
|
|
|
|
@ -132,7 +129,10 @@ func (rc* RepoCommits) BuildGraph() *CommitNode { |
|
|
|
|
|
|
|
func (rc* RepoCommits) FindLeafs() map[*CommitNode]Empty { |
|
|
|
toProcess := make(map[*CommitNode]Empty) |
|
|
|
toProcess[rc.Root] = empty |
|
|
|
|
|
|
|
for cn, _ := range rc.Root { |
|
|
|
toProcess[cn] = empty |
|
|
|
} |
|
|
|
|
|
|
|
for i := 0; i < len(rc.CommitContent) && len(toProcess) > 0; i++ { |
|
|
|
nextToProcess := make(map[*CommitNode]Empty) |
|
|
|