Skip to content

Commit

Permalink
Make registry load packages deterministically (#2945)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloserrano committed Oct 17, 2022
1 parent ab516bc commit 1dac1ac
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions internal/descriptor/registry.go
Expand Up @@ -2,6 +2,7 @@ package descriptor

import (
"fmt"
"sort"
"strings"

"github.com/golang/glog"
Expand Down Expand Up @@ -187,12 +188,18 @@ func (r *Registry) LoadFromPlugin(gen *protogen.Plugin) error {
}

func (r *Registry) load(gen *protogen.Plugin) error {
for filePath, f := range gen.FilesByPath {
r.loadFile(filePath, f)
filePaths := make([]string, 0, len(gen.FilesByPath))
for filePath := range gen.FilesByPath {
filePaths = append(filePaths, filePath)
}
sort.Strings(filePaths)

for filePath, f := range gen.FilesByPath {
if !f.Generate {
for _, filePath := range filePaths {
r.loadFile(filePath, gen.FilesByPath[filePath])
}

for _, filePath := range filePaths {
if !gen.FilesByPath[filePath].Generate {
continue
}
file := r.files[filePath]
Expand Down

0 comments on commit 1dac1ac

Please sign in to comment.