From 9541470633b0dc0152716c7d8f89d51e464a1a00 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Wed, 8 Feb 2023 18:36:38 -0800 Subject: [PATCH] disable slow parsing of additions and deletions --- cmd/mgfetch/mgfetch.go | 6 ++++-- commits/chancommits.go | 21 +++++++++++++-------- commits/commits.go | 20 +++++++++++--------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/cmd/mgfetch/mgfetch.go b/cmd/mgfetch/mgfetch.go index 1e6afd6..185e24d 100644 --- a/cmd/mgfetch/mgfetch.go +++ b/cmd/mgfetch/mgfetch.go @@ -14,7 +14,9 @@ type Repo git.Repository func main() { year := time.Now().Year() - authors := []string{"Groot"} + aName, _ := commits.GetAuthorName() + aEmail, _ := commits.GetAuthorEmail() + authors := []string{aName, aEmail} mr, err := commits.GetMRRepos() if err != nil { panic(err) @@ -23,7 +25,7 @@ func main() { fmt.Println("found no repos!") os.Exit(1) } - gfreq, err := mr.FrequencyChan(year, authors) + gfreq, err := mr.Frequency(year, authors) if err != nil { panic(err) } diff --git a/commits/chancommits.go b/commits/chancommits.go index cc8b51c..ee800d6 100644 --- a/commits/chancommits.go +++ b/commits/chancommits.go @@ -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 }) diff --git a/commits/commits.go b/commits/commits.go index 2cf3676..e15bd91 100644 --- a/commits/commits.go +++ b/commits/commits.go @@ -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 })