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

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

View File

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