From 62780ba810dcf0e178ab5646d4a6b888a72d83ad Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Mon, 30 Jan 2023 22:25:00 -0800 Subject: [PATCH] reorder funcs by usage order --- commits/chancommits.go | 46 +++++++++++++++++++++--------------------- commits/commits.go | 44 ++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/commits/chancommits.go b/commits/chancommits.go index 5c00dcc..c4878ab 100644 --- a/commits/chancommits.go +++ b/commits/chancommits.go @@ -58,6 +58,29 @@ func GlobalFrequencyChan(year int, authors []string) (types.YearFreq, error) { return freq, nil } +func (repo Repo) GetCommitChan() (chan types.Commit, error) { + cc := make(chan types.Commit, 30) + r := git.Repository(repo) + ref, err := r.Head() + if err != nil { + return cc, err + } + cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) + if err != nil { + return cc, err + } + go func() { + cIter.ForEach(func(c *object.Commit) error { + ts := c.Author.When + commit := types.Commit{Author: c.Author.Name, Message: c.Message, TimeStamp: ts} + cc <- commit + return nil + }) + close(cc) + }() + return cc, nil +} + func YearFreqFromChan(cc chan types.Commit, year int) types.YearFreq { yearLength := 365 if year%4 == 0 { @@ -110,26 +133,3 @@ func FilterCChanByAuthor(in chan types.Commit, authors []string) (chan types.Com }() return out, nil } - -func (repo Repo) GetCommitChan() (chan types.Commit, error) { - cc := make(chan types.Commit, 30) - r := git.Repository(repo) - ref, err := r.Head() - if err != nil { - return cc, err - } - cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) - if err != nil { - return cc, err - } - go func() { - cIter.ForEach(func(c *object.Commit) error { - ts := c.Author.When - commit := types.Commit{Author: c.Author.Name, Message: c.Message, TimeStamp: ts} - cc <- commit - return nil - }) - close(cc) - }() - return cc, nil -} diff --git a/commits/commits.go b/commits/commits.go index 7833f51..d2f5f33 100644 --- a/commits/commits.go +++ b/commits/commits.go @@ -42,6 +42,28 @@ func GlobalFrequency(year int, authors []string) (types.YearFreq, error) { return gfreq, nil } +func (repo Repo) GetCommitSet() (CommitSet, error) { + cs := CommitSet{} + commits := []types.Commit{} + r := git.Repository(repo) + ref, err := r.Head() + if err != nil { + return cs, err + } + cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) + if err != nil { + return cs, err + } + cIter.ForEach(func(c *object.Commit) error { + ts := c.Author.When + commit := types.Commit{Author: c.Author.Name, Message: c.Message, TimeStamp: ts} + commits = append(commits, commit) + return nil + }) + cs.Commits = commits + return cs, nil +} + func (cs CommitSet) ToYearFreq() types.YearFreq { year := cs.Year yearLength := 365 @@ -106,25 +128,3 @@ func (cs CommitSet) FilterByYear(year int) CommitSet { } return newCS } - -func (repo Repo) GetCommitSet() (CommitSet, error) { - cs := CommitSet{} - commits := []types.Commit{} - r := git.Repository(repo) - ref, err := r.Head() - if err != nil { - return cs, err - } - cIter, err := r.Log(&git.LogOptions{From: ref.Hash()}) - if err != nil { - return cs, err - } - cIter.ForEach(func(c *object.Commit) error { - ts := c.Author.When - commit := types.Commit{Author: c.Author.Name, Message: c.Message, TimeStamp: ts} - commits = append(commits, commit) - return nil - }) - cs.Commits = commits - return cs, nil -}