-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (47 loc) · 1.25 KB
/
main.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
package main
import (
"fmt"
"log"
"os"
"github.com/mocksi/diffdash-drone/analysis"
"github.com/mocksi/diffdash-drone/storage"
)
func main() {
if len(os.Args) < 2 {
log.Fatalf("Usage: %s <path-to-repo>", os.Args[1])
}
// TODO: allow config to be configurable by the user
config := storage.Config{
BaseBranch: "main",
StoragePath: "./",
RepoPath: os.Args[1],
}
// TODO: allow StoragePath to be configurable by the user
repoDatabase, err := storage.SetupDuckDb(config)
if err != nil {
log.Fatalf("Could not create DB: %v", err)
}
var numCommits int
err = analysis.CountCommits(repoDatabase).Scan(&numCommits)
if err != nil {
log.Fatalf("Could not open DB: %v", err)
}
if numCommits < 1 {
fmt.Println("No commits found. Extracting commits...")
err = repoDatabase.ExtractCommits()
if err != nil {
log.Fatalf("Error processing commits: %v", err)
}
}
fmt.Println("Successfully processed all commits.")
err = analysis.FindBugspots(repoDatabase)
if err != nil {
log.Fatalf("Error finding bugspots commits: %v", err)
}
fmt.Println("Successfully found bugspots. Analyzing bugspots...")
err = analysis.AnalyzeWithLLM(repoDatabase)
if err != nil {
log.Fatalf("Error analyzing bugspots: %v", err)
}
defer repoDatabase.Close()
}