Parse commits
This commit is contained in:
parent
3ed9f15672
commit
dfcc8993ca
1 changed files with 24 additions and 0 deletions
24
commit.go
24
commit.go
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -10,6 +11,13 @@ type RepoCommits struct {
|
||||||
Config configCollect
|
Config configCollect
|
||||||
CommitDesc map[string]string
|
CommitDesc map[string]string
|
||||||
CommitContent map[string]Commit
|
CommitContent map[string]Commit
|
||||||
|
Head *CommitNode
|
||||||
|
}
|
||||||
|
|
||||||
|
type CommitNode struct {
|
||||||
|
Parents []*CommitNode
|
||||||
|
Children []*CommitNode
|
||||||
|
Content Commit
|
||||||
}
|
}
|
||||||
|
|
||||||
type Commit struct {
|
type Commit struct {
|
||||||
|
@ -31,8 +39,12 @@ type Commit struct {
|
||||||
|
|
||||||
func cmdCommit(config configCollect) {
|
func cmdCommit(config configCollect) {
|
||||||
rc := NewRepoCommits(config)
|
rc := NewRepoCommits(config)
|
||||||
|
|
||||||
rc.CollectDescs()
|
rc.CollectDescs()
|
||||||
rc.PrintDescs()
|
rc.PrintDescs()
|
||||||
|
|
||||||
|
rc.CollectContent()
|
||||||
|
//rc.BuildGraph()
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRepoCommits (config configCollect) *RepoCommits {
|
func NewRepoCommits (config configCollect) *RepoCommits {
|
||||||
|
@ -72,3 +84,15 @@ func (rc* RepoCommits) PrintDescs() {
|
||||||
}
|
}
|
||||||
log.Println("Repo", rc.Config.RepoId, "contains", len(rc.CommitDesc), "commits")
|
log.Println("Repo", rc.Config.RepoId, "contains", len(rc.CommitDesc), "commits")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rc* RepoCommits) CollectContent() {
|
||||||
|
for id, path := range rc.CommitDesc {
|
||||||
|
data, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil { log.Fatal(err) }
|
||||||
|
|
||||||
|
var c Commit
|
||||||
|
json.Unmarshal(data, &c)
|
||||||
|
rc.CommitContent[id] = c
|
||||||
|
log.Println(rc.CommitContent[id])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue