From 5dee9d74a6221d89cd9c3f276079c3a3548c1780 Mon Sep 17 00:00:00 2001 From: Ernesto Casablanca <65033249+TendTo@users.noreply.github.com> Date: Mon, 20 May 2024 11:02:15 +0000 Subject: [PATCH] fix: correct links for versions higher than 6 --- src/segments/bazel.go | 4 ++-- src/segments/bazel_test.go | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/segments/bazel.go b/src/segments/bazel.go index 0c146cd5..ff97002c 100644 --- a/src/segments/bazel.go +++ b/src/segments/bazel.go @@ -33,8 +33,8 @@ func (c *Bazel) Init(props properties.Properties, env platform.Environment) { regex: `bazel (?P((?P[0-9]+).(?P[0-9]+).(?P[0-9]+)))`, }, }, - // Use the correct URL for Bazel 6.x. it does not have the docs subdomain. - versionURLTemplate: "https://{{ if ne .Major \"6\" }}docs.{{ end }}bazel.build/versions/{{ .Major }}.{{ .Minor }}.{{ .Patch }}", + // Use the correct URL for Bazel >5.4.1, since they do not have the docs subdomain. + versionURLTemplate: "https://{{ if lt .Major 6 }}docs.{{ end }}bazel.build/versions/{{ .Major }}.{{ .Minor }}.{{ .Patch }}", } c.Icon = props.GetString(Icon, "\ue63a") } diff --git a/src/segments/bazel_test.go b/src/segments/bazel_test.go index 243cdd7d..72ff2131 100644 --- a/src/segments/bazel_test.go +++ b/src/segments/bazel_test.go @@ -14,9 +14,12 @@ func TestBazel(t *testing.T) { Version string Template string }{ + {Case: "bazel 4.0.0", ExpectedString: "https://docs.bazel.build/versions/4.0.0\ue63a 4.0.0", Version: "bazel 4.0.0", Template: ""}, + {Case: "bazel 5.4.1", ExpectedString: "https://docs.bazel.build/versions/5.4.1\ue63a 5.4.1", Version: "bazel 5.4.1", Template: ""}, {Case: "bazel 6.4.0", ExpectedString: "https://bazel.build/versions/6.4.0\ue63a 6.4.0", Version: "bazel 6.4.0", Template: ""}, - {Case: "bazel 10.11.12", ExpectedString: "https://docs.bazel.build/versions/3.7.0\ue63a 3.7.0", Version: "bazel 3.7.0"}, - {Case: "", ExpectedString: "\ue63a err parsing info from bazel with", Version: ""}, + {Case: "bazel 7.1.1", ExpectedString: "https://bazel.build/versions/7.1.1\ue63a 7.1.1", Version: "bazel 7.1.1", Template: ""}, + {Case: "bazel 10.11.12", ExpectedString: "https://bazel.build/versions/10.11.12\ue63a 10.11.12", Version: "bazel 10.11.12", Template: ""}, + {Case: "", ExpectedString: "\ue63a err parsing info from bazel with", Version: "", Template: ""}, } for _, tc := range cases { params := &mockedLanguageParams{