disable slow parsing of additions and deletions

This commit is contained in:
2023-02-08 18:36:38 -08:00
parent 7d080ff153
commit 9541470633
3 changed files with 28 additions and 19 deletions

View File

@@ -14,7 +14,9 @@ type Repo git.Repository
func main() { func main() {
year := time.Now().Year() year := time.Now().Year()
authors := []string{"Groot"} aName, _ := commits.GetAuthorName()
aEmail, _ := commits.GetAuthorEmail()
authors := []string{aName, aEmail}
mr, err := commits.GetMRRepos() mr, err := commits.GetMRRepos()
if err != nil { if err != nil {
panic(err) panic(err)
@@ -23,7 +25,7 @@ func main() {
fmt.Println("found no repos!") fmt.Println("found no repos!")
os.Exit(1) os.Exit(1)
} }
gfreq, err := mr.FrequencyChan(year, authors) gfreq, err := mr.Frequency(year, authors)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@@ -1,6 +1,7 @@
package commits package commits
import ( import (
"fmt"
"regexp" "regexp"
"sync" "sync"
@@ -60,6 +61,7 @@ func YearFreqFromChan(cc chan types.Commit, year int) types.Freq {
freq := make([]int, yearLength) freq := make([]int, yearLength)
for commit := range cc { for commit := range cc {
freq[commit.TimeStamp.YearDay()-1]++ freq[commit.TimeStamp.YearDay()-1]++
fmt.Println(commit)
} }
return freq return freq
} }
@@ -69,10 +71,12 @@ func (repo Repo) GetCommitChan() (chan types.Commit, error) {
r := git.Repository(repo.Repo) r := git.Repository(repo.Repo)
ref, err := r.Head() ref, err := r.Head()
if err != nil { if err != nil {
close(cc)
return cc, err return cc, err
} }
cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) cIter, err := r.Log(&git.LogOptions{From: ref.Hash()})
if err != nil { if err != nil {
close(cc)
return cc, err return cc, err
} }
go func() { go func() {
@@ -84,14 +88,15 @@ func (repo Repo) GetCommitChan() (chan types.Commit, error) {
Hash: c.Hash.String(), Repo: repo.Path, Hash: c.Hash.String(), Repo: repo.Path,
FilesChanged: 0, Added: 0, Deleted: 0, FilesChanged: 0, Added: 0, Deleted: 0,
} }
stats, err := c.Stats() // Too slow, commenting for now
if err != nil { // stats, err := c.Stats()
for _, stat := range stats { // if err != nil {
commit.Added += stat.Addition // for _, stat := range stats {
commit.Deleted += stat.Deletion // commit.Added += stat.Addition
commit.FilesChanged++ // commit.Deleted += stat.Deletion
} // commit.FilesChanged++
} // }
// }
cc <- commit cc <- commit
return nil return nil
}) })

View File

@@ -1,6 +1,7 @@
package commits package commits
import ( import (
"log"
"regexp" "regexp"
"time" "time"
@@ -48,7 +49,7 @@ func (paths RepoSet) Frequency(year int, authors []string) (types.Freq, error) {
} }
commits, err := repo.GetCommitSet() commits, err := repo.GetCommitSet()
if err != nil { if err != nil {
return types.Freq{}, err log.Printf("skipping repo %s\n", repo.Path)
} }
commits = commits.FilterByYear(year) commits = commits.FilterByYear(year)
commits, err = commits.FilterByAuthorRegex(authors) commits, err = commits.FilterByAuthorRegex(authors)
@@ -93,14 +94,15 @@ func (repo Repo) GetCommitSet() (CommitSet, error) {
Hash: c.Hash.String(), Repo: repo.Path, Hash: c.Hash.String(), Repo: repo.Path,
FilesChanged: 0, Added: 0, Deleted: 0, FilesChanged: 0, Added: 0, Deleted: 0,
} }
stats, err := c.Stats() // this is too slow for now, so skipping
if err != nil { // stats, err := c.Stats()
for _, stat := range stats { // if err != nil {
commit.Added += stat.Addition // for _, stat := range stats {
commit.Deleted += stat.Deletion // commit.Added += stat.Addition
commit.FilesChanged++ // commit.Deleted += stat.Deletion
} // commit.FilesChanged++
} // }
// }
commits = append(commits, commit) commits = append(commits, commit)
return nil return nil
}) })