Bugfix: Force binary rebuild

We need to rebuild the binary whenever the plugin has changed.
Previously we were not doing this if the binary already existed. This MR
adds an override parameter to the build() function which will force a
rebuild even if the binary already exists.

The README has been updated to note that this parameter should be used
for Packer/Lazy, and when someone is troubleshooting. It won't be passed
in to the build function during the normal setup call.

Should address #55
This commit is contained in:
Harrison Cramer
2023-09-04 11:44:24 -04:00
parent 6cb9d2887c
commit ac2118ceb6
2 changed files with 8 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
-- This module contains the logic responsible for building and starting
-- the Golang server. The Go server is responsible for making API calls
-- to Gitlab and returning the data
local job = require("gitlab.job")
local state = require("gitlab.state")
local u = require("gitlab.utils")
local M = {}
@@ -43,7 +42,7 @@ end
-- Builds the Go binary
M.build = function()
M.build = function(override)
if not u.has_delta() then
vim.notify("Please install delta to use gitlab.nvim!", vim.log.levels.ERROR)
return
@@ -54,8 +53,10 @@ M.build = function()
state.settings.bin_path = parent_dir
state.settings.bin = parent_dir .. "/bin"
local binary_exists = vim.loop.fs_stat(state.settings.bin)
if binary_exists ~= nil then return end
if not override then
local binary_exists = vim.loop.fs_stat(state.settings.bin)
if binary_exists ~= nil then return end
end
local command = string.format("cd %s && make", state.settings.bin_path)
local installCode = os.execute(command .. "> /dev/null")