mirror of
https://github.com/taigrr/gico.git
synced 2026-04-02 03:09:07 -07:00
reorder funcs by usage order
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user