Skip to content

Commit

Permalink
Chore: support the new versioning scheme of Protobuf
Browse files Browse the repository at this point in the history
Protobuf has changed their versioning scheme to language-specific one. For Golang, the first version applied the scheme would be 4.21.0 which followed the preceding version,3.20.1. Basically the major part is language-specific and no longer important.
Check more:
https://protobuf.dev/news/2022-05-06/
protocolbuffers/protobuf#11440
protocolbuffers/protobuf#11123
  • Loading branch information
wegood9 committed Aug 4, 2023
1 parent d586497 commit dcca022
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion infra/vprotogen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func getInstalledProtocVersion(protocPath string) (string, error) {
if cmdErr != nil {
return "", cmdErr
}
versionRegexp := regexp.MustCompile(`protoc\s*(\d+\.\d+\.\d+)`)
versionRegexp := regexp.MustCompile(`protoc\s*(\d+\.\d+(\.\d)*)`)
matched := versionRegexp.FindStringSubmatch(string(output))
return matched[1], nil
}
Expand All @@ -129,6 +129,9 @@ func parseVersion(s string, width int) int64 {
strList := strings.Split(s, ".")
format := fmt.Sprintf("%%s%%0%ds", width)
v := ""
if len(strList) == 2 {
strList = append([]string{"4"}, strList...)
}
for _, value := range strList {
v = fmt.Sprintf(format, v, value)
}
Expand Down

0 comments on commit dcca022

Please sign in to comment.