diff options
| author | William Boman <william@redwill.se> | 2023-06-21 18:42:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-21 18:42:34 +0200 |
| commit | e706d305fbcc8701bd30e31dd727aee2853b9db9 (patch) | |
| tree | 7baf556871a7737b4a01abdc05a1d6e8f8fa5ea7 | |
| parent | chore(main): release 1.3.0 (#1359) (diff) | |
| download | mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.tar mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.tar.gz mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.tar.bz2 mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.tar.lz mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.tar.xz mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.tar.zst mason-e706d305fbcc8701bd30e31dd727aee2853b9db9.zip | |
feat(fetch): include mason.nvim version in User-Agent (#1362)
| -rw-r--r-- | lua/mason-core/fetch.lua | 3 | ||||
| -rw-r--r-- | tests/mason-core/fetch_spec.lua | 17 |
2 files changed, 15 insertions, 5 deletions
diff --git a/lua/mason-core/fetch.lua b/lua/mason-core/fetch.lua index da76d620..545c8440 100644 --- a/lua/mason-core/fetch.lua +++ b/lua/mason-core/fetch.lua @@ -6,8 +6,9 @@ local log = require "mason-core.log" local platform = require "mason-core.platform" local powershell = require "mason-core.managers.powershell" local spawn = require "mason-core.spawn" +local version = require "mason.version" -local USER_AGENT = "mason.nvim (+https://github.com/williamboman/mason.nvim)" +local USER_AGENT = ("mason.nvim %s (+https://github.com/williamboman/mason.nvim)"):format(version.VERSION) ---@alias FetchMethod ---| '"GET"' diff --git a/tests/mason-core/fetch_spec.lua b/tests/mason-core/fetch_spec.lua index 7a25a693..39351abe 100644 --- a/tests/mason-core/fetch_spec.lua +++ b/tests/mason-core/fetch_spec.lua @@ -3,6 +3,7 @@ local fetch = require "mason-core.fetch" local match = require "luassert.match" local spawn = require "mason-core.spawn" local stub = require "luassert.stub" +local version = require "mason.version" describe("fetch", function() it( @@ -21,7 +22,9 @@ describe("fetch", function() assert.spy(spawn.curl).was_called(1) assert.spy(spawn.wget).was_called_with { { - "--header=User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)", + ("--header=User-Agent: mason.nvim %s (+https://github.com/williamboman/mason.nvim)"):format( + version.VERSION + ), "--header=X-Custom-Header: here", }, "-nv", @@ -38,7 +41,9 @@ describe("fetch", function() match.same { { "-H", - "User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)", + ("User-Agent: mason.nvim %s (+https://github.com/williamboman/mason.nvim)"):format( + version.VERSION + ), }, { "-H", @@ -79,7 +84,9 @@ describe("fetch", function() assert.spy(spawn.wget).was_called_with { { - "--header=User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)", + ("--header=User-Agent: mason.nvim %s (+https://github.com/williamboman/mason.nvim)"):format( + version.VERSION + ), }, "-nv", "-o", @@ -95,7 +102,9 @@ describe("fetch", function() match.same { { "-H", - "User-Agent: mason.nvim (+https://github.com/williamboman/mason.nvim)", + ("User-Agent: mason.nvim %s (+https://github.com/williamboman/mason.nvim)"):format( + version.VERSION + ), }, }, "-fsSL", |
