fix git parsing and init
- run `ls ROOT_PATH` on init to make sure we are in the right place - match git path with `.*` to make sure we check when in a subdir > it could cause issues though, fix this later with a better > git interface
This commit is contained in:
parent
e85dc5eb0f
commit
f397e1050c
@ -24,5 +24,3 @@
|
||||
- cd command to move faster accross the fs if needed
|
||||
- quickly find file in the directory structure
|
||||
- use libuv functions instead of `touch` and `mkdir` in `add_file()`
|
||||
- fix colors fucks up on refresh sometimes (and git is wrong when cd into a subdirectory)
|
||||
|
||||
|
||||
@ -35,7 +35,8 @@ end
|
||||
local function create_git_checker(pattern)
|
||||
return function(relpath)
|
||||
for _, status in pairs(GIT_STATUS) do
|
||||
local ret = string.match(status, '^.. ' .. relpath)
|
||||
-- TODO: fix .* as it could be problematic
|
||||
local ret = string.match(status, '^.. .*' .. relpath)
|
||||
if ret ~= nil and string.match(ret, pattern) ~= nil then return true end
|
||||
end
|
||||
return false
|
||||
|
||||
@ -30,14 +30,12 @@ local function check_dir_access(path)
|
||||
end
|
||||
|
||||
local function list_dirs(path)
|
||||
local ls_cmd = 'ls -A --ignore=.git '
|
||||
if path == nil then
|
||||
return syslist(ls_cmd)
|
||||
elseif check_dir_access(path) == false then
|
||||
if check_dir_access(path) == false then
|
||||
-- TODO: display an error here (permission denied)
|
||||
return {}
|
||||
else
|
||||
return syslist(ls_cmd .. path)
|
||||
local ls_cmd = 'ls -A --ignore=.git ' ..path
|
||||
return syslist(ls_cmd)
|
||||
end
|
||||
end
|
||||
|
||||
@ -84,7 +82,7 @@ local function create_nodes(path, relpath, depth, dirs)
|
||||
end
|
||||
|
||||
local function init_tree()
|
||||
Tree = create_nodes(ROOT_PATH, '', 0, list_dirs())
|
||||
Tree = create_nodes(ROOT_PATH, '', 0, list_dirs(ROOT_PATH))
|
||||
if ROOT_PATH ~= '/' then
|
||||
table.insert(Tree, 1, {
|
||||
path = ROOT_PATH,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user