Skip to content

Commit

Permalink
fix client version parser (#673)
Browse files Browse the repository at this point in the history
Signed-off-by: xixi <[email protected]>
  • Loading branch information
Hexilee authored Jun 20, 2023
1 parent 11134b4 commit f520a36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/juicefs/juicefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func parseRawVersion(rawVersion string) (*clientVersion, error) {
}

func parseVersion(version string) (*clientVersion, error) {
re := regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$`)
re := regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)(?:[+-](.+))?$`)
matches := re.FindStringSubmatch(strings.TrimSpace(version))
if matches == nil {
return nil, fmt.Errorf("invalid version string: %s", version)
Expand Down
9 changes: 9 additions & 0 deletions pkg/juicefs/juicefs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,15 @@ func Test_parseRawVersion(t *testing.T) {
Patch: 0,
},
},
{
name: "test-normal5",
raw: "juicefs version 1.0.4+2023-04-06.f1c475d9",
want: clientVersion{
Major: 1,
Minor: 0,
Patch: 4,
},
},
{
name: "test-error",
raw: "juicefs version 0.11",
Expand Down

0 comments on commit f520a36

Please sign in to comment.