-
Notifications
You must be signed in to change notification settings - Fork 1
/
coordinator.go
66 lines (50 loc) · 1.18 KB
/
coordinator.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package inspector
import (
"github.com/libgit2/git2go"
)
const DEPTH = 100
type Coordinator struct {
RepoName string
}
func NewCoordinator(repo string) *Coordinator {
return &Coordinator{
RepoName: repo,
}
}
func (c *Coordinator) Heatmap() string {
repo, _ := GetRepo(c.RepoName)
defer repo.Free()
defer CleanTempDir()
total := 0
// files := createFilesFromPaths(ListFiles(repo.Path()))
WalkCommits(repo, func(previous, current *git.Commit) bool {
if total >= DEPTH {
return false
} else {
total += 1
}
diff, err := GetDiff(repo, previous, current)
if err != nil {
return false
}
defer diff.Free()
WalkHunks(diff, func(file git.DiffDelta, hunk git.DiffHunk) {
//File modified
// blob, err := repo.LookupBlob(file.NewFile.Oid)
// if err != nil {
// panic("Cannot lookup blob, error: " + err.Error())
// }
//
// totalBytes += len(blob.Contents())
// blob.Free()
//TODO:
// - Checkout at the given commit
// - Get AST to parse the given commit
// - Run unitHunk.Intersects(*unitAst)
// - Flag if true
// units = append(units, *UnitFromHunk(file.NewFile, hunk))
})
return true
})
return c.RepoName
}