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
|
- cd command to move faster accross the fs if needed
|
||||||
- quickly find file in the directory structure
|
- quickly find file in the directory structure
|
||||||
- use libuv functions instead of `touch` and `mkdir` in `add_file()`
|
- 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)
|
local function create_git_checker(pattern)
|
||||||
return function(relpath)
|
return function(relpath)
|
||||||
for _, status in pairs(GIT_STATUS) do
|
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
|
if ret ~= nil and string.match(ret, pattern) ~= nil then return true end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -30,14 +30,12 @@ local function check_dir_access(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function list_dirs(path)
|
local function list_dirs(path)
|
||||||
local ls_cmd = 'ls -A --ignore=.git '
|
if check_dir_access(path) == false then
|
||||||
if path == nil then
|
|
||||||
return syslist(ls_cmd)
|
|
||||||
elseif check_dir_access(path) == false then
|
|
||||||
-- TODO: display an error here (permission denied)
|
-- TODO: display an error here (permission denied)
|
||||||
return {}
|
return {}
|
||||||
else
|
else
|
||||||
return syslist(ls_cmd .. path)
|
local ls_cmd = 'ls -A --ignore=.git ' ..path
|
||||||
|
return syslist(ls_cmd)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -84,7 +82,7 @@ local function create_nodes(path, relpath, depth, dirs)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function init_tree()
|
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
|
if ROOT_PATH ~= '/' then
|
||||||
table.insert(Tree, 1, {
|
table.insert(Tree, 1, {
|
||||||
path = ROOT_PATH,
|
path = ROOT_PATH,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user