fix: correct links for versions higher than 6

This commit is contained in:
Ernesto Casablanca 2024-05-20 11:02:15 +00:00 committed by Jan De Dobbeleer
parent be9faf1a2c
commit 5dee9d74a6
2 changed files with 7 additions and 4 deletions

View file

@ -33,8 +33,8 @@ func (c *Bazel) Init(props properties.Properties, env platform.Environment) {
regex: `bazel (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`, regex: `bazel (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
}, },
}, },
// Use the correct URL for Bazel 6.x. it does not have the docs subdomain. // Use the correct URL for Bazel >5.4.1, since they do not have the docs subdomain.
versionURLTemplate: "https://{{ if ne .Major \"6\" }}docs.{{ end }}bazel.build/versions/{{ .Major }}.{{ .Minor }}.{{ .Patch }}", versionURLTemplate: "https://{{ if lt .Major 6 }}docs.{{ end }}bazel.build/versions/{{ .Major }}.{{ .Minor }}.{{ .Patch }}",
} }
c.Icon = props.GetString(Icon, "\ue63a") c.Icon = props.GetString(Icon, "\ue63a")
} }

View file

@ -14,9 +14,12 @@ func TestBazel(t *testing.T) {
Version string Version string
Template string Template string
}{ }{
{Case: "bazel 4.0.0", ExpectedString: "<LINK>https://docs.bazel.build/versions/4.0.0<TEXT>\ue63a</TEXT></LINK> 4.0.0", Version: "bazel 4.0.0", Template: ""},
{Case: "bazel 5.4.1", ExpectedString: "<LINK>https://docs.bazel.build/versions/5.4.1<TEXT>\ue63a</TEXT></LINK> 5.4.1", Version: "bazel 5.4.1", Template: ""},
{Case: "bazel 6.4.0", ExpectedString: "<LINK>https://bazel.build/versions/6.4.0<TEXT>\ue63a</TEXT></LINK> 6.4.0", Version: "bazel 6.4.0", Template: ""}, {Case: "bazel 6.4.0", ExpectedString: "<LINK>https://bazel.build/versions/6.4.0<TEXT>\ue63a</TEXT></LINK> 6.4.0", Version: "bazel 6.4.0", Template: ""},
{Case: "bazel 10.11.12", ExpectedString: "<LINK>https://docs.bazel.build/versions/3.7.0<TEXT>\ue63a</TEXT></LINK> 3.7.0", Version: "bazel 3.7.0"}, {Case: "bazel 7.1.1", ExpectedString: "<LINK>https://bazel.build/versions/7.1.1<TEXT>\ue63a</TEXT></LINK> 7.1.1", Version: "bazel 7.1.1", Template: ""},
{Case: "", ExpectedString: "\ue63a err parsing info from bazel with", Version: ""}, {Case: "bazel 10.11.12", ExpectedString: "<LINK>https://bazel.build/versions/10.11.12<TEXT>\ue63a</TEXT></LINK> 10.11.12", Version: "bazel 10.11.12", Template: ""},
{Case: "", ExpectedString: "\ue63a err parsing info from bazel with", Version: "", Template: ""},
} }
for _, tc := range cases { for _, tc := range cases {
params := &mockedLanguageParams{ params := &mockedLanguageParams{