Skip to content

Commit

Permalink
fix(devpod): check devpod/docker executable is available
Browse files Browse the repository at this point in the history
  • Loading branch information
amitds1997 committed May 22, 2024
1 parent 7e8b322 commit f63fae1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lua/remote-nvim/providers/devpod/devpod_provider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function DevpodProvider:init(opts)
assert(opts.host ~= nil, "Host cannot be nil")
assert(opts.devpod_opts ~= nil, "Devpod options should not be nil")
assert(opts.devpod_opts.source ~= nil, "Source should not be nil")
assert(
vim.fn.executable(remote_nvim.config.devpod.binary) == 1,
("Devpod binary '%s' not found"):format(remote_nvim.config.devpod.binary)
)

self.unique_host_id = opts.unique_host_id
self.host = ("%s.devpod"):format(self.unique_host_id)
Expand Down
18 changes: 16 additions & 2 deletions lua/telescope/_extensions/choices/init.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
---@type remote-nvim.RemoteNeovim
local remote_nvim = require("remote-nvim")

local function gen_choices()
local choices = {}

local curr_path = vim.fs.dirname(debug.getinfo(1).source:sub(2))
assert(curr_path ~= nil, "File path to the current file should not be nil")

local files = vim.fs.find(function(name, _)
return name ~= "init.lua"
local should_include_devpod_choices = vim.fn.executable(remote_nvim.config.devpod.binary) == 1
local should_include_docker_choices = vim.fn.executable(remote_nvim.config.devpod.docker_binary) == 1

local files = vim.fs.find(function(name, path)
local should_include = name ~= "init.lua"

if not should_include_devpod_choices or not should_include_docker_choices then
local devpod_start, _ = path:find("devpod", nil, true)
local docker_start, _ = path:find("docker", nil, true)
should_include = should_include and (devpod_start == nil) and (docker_start == nil)
end

return should_include
end, {
type = "file",
limit = math.huge,
Expand Down
4 changes: 3 additions & 1 deletion tests/remote-nvim/providers/devpod/devpod_provider_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ local stub = require("luassert.stub")

-- _launch_devpod_workspace
describe("Provider", function()
local progress_viewer
local progress_viewer, executable_stub
before_each(function()
progress_viewer = mock(require("remote-nvim.ui.progressview"), true)
executable_stub = stub(vim.fn, "executable")
executable_stub.returns(1)
end)

describe("should initialize correctly", function()
Expand Down

0 comments on commit f63fae1

Please sign in to comment.