diff options
author | Michael Muré <batolettre@gmail.com> | 2022-11-15 19:36:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-15 19:36:46 +0100 |
commit | 733c7c6b3ebe1fb322d8107fdf6dae7a6060b87b (patch) | |
tree | 1d912649aa75dedb05ead99603039d8f0dc77950 /repository/gogit.go | |
parent | 432e4f25ffcfda54c711092f3ca418631ffca0aa (diff) | |
parent | d1744f5ee2c55176bb877f7d13b92efd29877077 (diff) | |
download | git-bug-733c7c6b3ebe1fb322d8107fdf6dae7a6060b87b.tar.gz |
Merge pull request #916 from MichaelMure/repo-parallel-clock-loading
go-git: concurrent loading of clocks
Diffstat (limited to 'repository/gogit.go')
-rw-r--r-- | repository/gogit.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/repository/gogit.go b/repository/gogit.go index 4e3ccfb8..7dd5a48d 100644 --- a/repository/gogit.go +++ b/repository/gogit.go @@ -20,6 +20,7 @@ import ( "github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing/filemode" "github.com/go-git/go-git/v5/plumbing/object" + "golang.org/x/sync/errgroup" "golang.org/x/sys/execabs" "github.com/MichaelMure/git-bug/util/lamport" @@ -79,7 +80,9 @@ func OpenGoGitRepo(path, namespace string, clockLoaders []ClockLoader) (*GoGitRe localStorage: osfs.New(filepath.Join(path, namespace)), } + loaderToRun := make([]ClockLoader, len(clockLoaders)) for _, loader := range clockLoaders { + loader := loader allExist := true for _, name := range loader.Clocks { if _, err := repo.getClock(name); err != nil { @@ -88,13 +91,22 @@ func OpenGoGitRepo(path, namespace string, clockLoaders []ClockLoader) (*GoGitRe } if !allExist { - err = loader.Witnesser(repo) - if err != nil { - return nil, err - } + loaderToRun = append(loaderToRun, loader) } } + var errG errgroup.Group + for _, loader := range loaderToRun { + loader := loader + errG.Go(func() error { + return loader.Witnesser(repo) + }) + } + err = errG.Wait() + if err != nil { + return nil, err + } + return repo, nil } |