mirror of
https://github.com/taigrr/gico.git
synced 2026-04-02 03:09:07 -07:00
fix an error where the wait group never completes on uninitialized repo
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
git "github.com/go-git/go-git/v5"
|
git "github.com/go-git/go-git/v5"
|
||||||
@@ -12,12 +13,16 @@ import (
|
|||||||
type Repo git.Repository
|
type Repo git.Repository
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
year := time.Now().Year() - 1
|
year := time.Now().Year()
|
||||||
authors := []string{"Groot"}
|
authors := []string{"Groot"}
|
||||||
mr, err := commits.GetMRRepos()
|
mr, err := commits.GetMRRepos()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
if len(mr) == 0 {
|
||||||
|
fmt.Println("found no repos!")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
gfreq, err := mr.FrequencyChan(year, authors)
|
gfreq, err := mr.FrequencyChan(year, authors)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ func (paths RepoSet) FrequencyChan(year int, authors []string) (types.Freq, erro
|
|||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(path string) {
|
go func(path string) {
|
||||||
|
defer wg.Done()
|
||||||
repo, err := OpenRepo(path)
|
repo, err := OpenRepo(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -40,7 +41,6 @@ func (paths RepoSet) FrequencyChan(year int, authors []string) (types.Freq, erro
|
|||||||
for c := range cc {
|
for c := range cc {
|
||||||
outChan <- c
|
outChan <- c
|
||||||
}
|
}
|
||||||
wg.Done()
|
|
||||||
}(p)
|
}(p)
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user