Skip to content

Commit 17278db

Browse files
committed
Check go version only when building the server
1 parent 957d6dc commit 17278db

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

lua/gitlab/init.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ local summary = require("gitlab.actions.summary")
1212
local data = require("gitlab.actions.data")
1313
local assignees_and_reviewers = require("gitlab.actions.assignees_and_reviewers")
1414
local comment = require("gitlab.actions.comment")
15-
local version = require("gitlab.version")
1615
local pipeline = require("gitlab.actions.pipeline")
1716
local create_mr = require("gitlab.actions.create_mr")
1817
local approvals = require("gitlab.actions.approvals")
@@ -37,12 +36,6 @@ local function setup(args)
3736
args = {}
3837
end
3938

40-
local version_issue = version.check_go_version()
41-
if version_issue ~= nil then
42-
u.notify(version_issue, vim.log.levels.ERROR)
43-
return
44-
end
45-
4639
state.merge_settings(args) -- Merges user settings with default settings
4740
server.build() -- Builds the Go binary if it doesn't exist
4841
state.set_global_keymaps() -- Sets keymaps that are not bound to a specific buffer

lua/gitlab/server.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
local state = require("gitlab.state")
55
local u = require("gitlab.utils")
66
local job = require("gitlab.job")
7+
local version = require("gitlab.version")
78
local M = {}
89

910
-- Builds the binary if it doesn't exist, and starts the server. If the pre-existing binary has an older
@@ -23,8 +24,8 @@ M.build_and_start = function(callback)
2324
callback()
2425
return
2526
end
26-
M.get_version(function(version)
27-
if version.plugin_version ~= version.binary_version then
27+
M.get_version(function(versions)
28+
if versions.plugin_version ~= versions.binary_version then
2829
M.shutdown(function()
2930
if M.build(true) then
3031
M.start(callback)
@@ -116,6 +117,12 @@ M.build = function(override)
116117
return
117118
end
118119

120+
local version_issue = version.check_go_version()
121+
if version_issue ~= nil then
122+
u.notify(version_issue, vim.log.levels.ERROR)
123+
return
124+
end
125+
119126
-- If the user did not provide a path, we build it and place it in either the data path, or the
120127
-- first writable path we find in the runtime.
121128
local datapath = vim.fn.stdpath("data")
@@ -150,9 +157,9 @@ M.build = function(override)
150157
local version_output = vim
151158
.system({ "git", "describe", "--tags", "--always" }, { cwd = state.settings.root_path })
152159
:wait()
153-
local version = version_output.code == 0 and vim.trim(version_output.stdout) or "unknown"
160+
local plugin_version = version_output.code == 0 and vim.trim(version_output.stdout) or "unknown"
154161

155-
local ldflags = string.format("-X main.Version=%s", version)
162+
local ldflags = string.format("-X main.Version=%s", plugin_version)
156163
local res = vim
157164
.system(
158165
{ "go", "build", "-buildvcs=false", "-ldflags", ldflags, "-o", state.settings.server.binary },

0 commit comments

Comments
 (0)