Skip to content

Commit 704adef

Browse files
committed
fix: handle not being in a git repository after Saghen#275
1 parent 18e4438 commit 704adef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/blink/cmp/fuzzy/download.lua

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ function download.get_lib_extension()
1010
end
1111

1212
local root_dir = debug.getinfo(1).source:match('@?(.*/)')
13-
local repo_dir = vim.fs.root(root_dir, '.git')
1413
download.lib_path = root_dir .. '../../../../target/release/libblink_cmp_fuzzy' .. download.get_lib_extension()
1514
local version_path = root_dir .. '../../../../target/release/version.txt'
1615

@@ -72,6 +71,10 @@ end
7271

7372
--- @param cb fun(err: string | nil, tag: string | nil)
7473
function download.get_git_tag(cb)
74+
-- If repo_dir is nil, no git reposiory is found, similar to `out.code == 128`
75+
local repo_dir = vim.fs.root(root_dir, '.git')
76+
if not repo_dir then return vim.schedule(function() return cb() end) end
77+
7578
vim.system({ 'git', '--git-dir', vim.fs.joinpath(repo_dir, '.git'), "--work-tree", repo_dir, 'describe', '--tags', '--exact-match' }, { cwd = root_dir }, function(out)
7679
if out.code == 128 then return cb() end
7780
if out.code ~= 0 then

0 commit comments

Comments
 (0)