refactor(git): use more appropriate variable names (#82)
This commit is contained in:
@@ -102,23 +102,23 @@ local add = ya.sync(function(st, cwd, repo, changed)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local remove = ya.sync(function(st, cwd)
|
local remove = ya.sync(function(st, cwd)
|
||||||
local dir = st.dirs[cwd]
|
local repo = st.dirs[cwd]
|
||||||
if not dir then
|
if not repo then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
ya.render()
|
ya.render()
|
||||||
st.dirs[cwd] = nil
|
st.dirs[cwd] = nil
|
||||||
if not st.repos[dir] then
|
if not st.repos[repo] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, r in pairs(st.dirs) do
|
for _, r in pairs(st.dirs) do
|
||||||
if r == dir then
|
if r == repo then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
st.repos[dir] = nil
|
st.repos[repo] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function setup(st, opts)
|
local function setup(st, opts)
|
||||||
@@ -149,18 +149,18 @@ local function setup(st, opts)
|
|||||||
|
|
||||||
Linemode:children_add(function(self)
|
Linemode:children_add(function(self)
|
||||||
local url = self._file.url
|
local url = self._file.url
|
||||||
local dir = st.dirs[tostring(url:parent())]
|
local repo = st.dirs[tostring(url:parent())]
|
||||||
local change
|
local code
|
||||||
if dir then
|
if repo then
|
||||||
change = dir == CODES.excluded and CODES.ignored or st.repos[dir][tostring(url):sub(#dir + 2)]
|
code = repo == CODES.excluded and CODES.ignored or st.repos[repo][tostring(url):sub(#repo + 2)]
|
||||||
end
|
end
|
||||||
|
|
||||||
if not change or signs[change] == "" then
|
if not code or signs[code] == "" then
|
||||||
return ""
|
return ""
|
||||||
elseif self._file:is_hovered() then
|
elseif self._file:is_hovered() then
|
||||||
return ui.Line { " ", signs[change] }
|
return ui.Line { " ", signs[code] }
|
||||||
else
|
else
|
||||||
return ui.Line { " ", ui.Span(signs[change]):style(styles[change]) }
|
return ui.Line { " ", ui.Span(signs[code]):style(styles[code]) }
|
||||||
end
|
end
|
||||||
end, opts.order)
|
end, opts.order)
|
||||||
end
|
end
|
||||||
@@ -191,11 +191,11 @@ local function fetch(_, job)
|
|||||||
|
|
||||||
local changed, excluded = {}, {}
|
local changed, excluded = {}, {}
|
||||||
for line in output.stdout:gmatch("[^\r\n]+") do
|
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||||
local sign, path = match(line)
|
local code, path = match(line)
|
||||||
if sign == CODES.excluded then
|
if code == CODES.excluded then
|
||||||
excluded[#excluded + 1] = path
|
excluded[#excluded + 1] = path
|
||||||
else
|
else
|
||||||
changed[path] = sign
|
changed[path] = code
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -204,8 +204,8 @@ local function fetch(_, job)
|
|||||||
end
|
end
|
||||||
ya.dict_merge(changed, propagate_down(excluded, cwd, Url(repo)))
|
ya.dict_merge(changed, propagate_down(excluded, cwd, Url(repo)))
|
||||||
|
|
||||||
for _, p in ipairs(paths) do
|
for _, path in ipairs(paths) do
|
||||||
local s = p:sub(#repo + 2)
|
local s = path:sub(#repo + 2)
|
||||||
changed[s] = changed[s] or CODES.unknown
|
changed[s] = changed[s] or CODES.unknown
|
||||||
end
|
end
|
||||||
add(tostring(cwd), repo, changed)
|
add(tostring(cwd), repo, changed)
|
||||||
|
|||||||
Reference in New Issue
Block a user