aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcukmekerb <cukmekerb@gmail.com>2021-08-18 11:58:49 -0700
committercukmekerb <cukmekerb@gmail.com>2021-08-18 11:58:49 -0700
commit6f776299a6642ca8cfc0fbed9e7d942891c92dc1 (patch)
tree5398a3618eb7e0a79bea76ce2ca4cae1dfef24ec
parente5b9da8119297e0e51b3f834a953955d3c8f3212 (diff)
downloadlite-xl-plugins-6f776299a6642ca8cfc0fbed9e7d942891c92dc1.tar.gz
lite-xl-plugins-6f776299a6642ca8cfc0fbed9e7d942891c92dc1.zip
use process api for gitstatus.lua
-rw-r--r--plugins/gitstatus.lua14
1 files changed, 5 insertions, 9 deletions
diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua
index b7ff5de..fda1388 100644
--- a/plugins/gitstatus.lua
+++ b/plugins/gitstatus.lua
@@ -13,13 +13,9 @@ local git = {
local function exec(cmd, wait)
- local tempfile = core.temp_filename()
- system.exec(string.format("%s > %q", cmd, tempfile))
- coroutine.yield(wait)
- local fp = io.open(tempfile)
- local res = fp:read("*a")
- fp:close()
- os.remove(tempfile)
+ local proc = process.start(cmd)
+ proc:wait(wait * 1000)
+ local res = proc:read_stdout()
return res
end
@@ -28,10 +24,10 @@ core.add_thread(function()
while true do
if system.get_file_info(".git") then
-- get branch name
- git.branch = exec("git rev-parse --abbrev-ref HEAD", 1):match("[^\n]*")
+ git.branch = exec({"git", "rev-parse", "--abbrev-ref", "HEAD"}, 1):match("[^\n]*")
-- get diff
- local line = exec("git diff --stat", 1):match("[^\n]*%s*$")
+ local line = exec({"git", "diff", "--stat"}, 1):match("[^\n]*%s*$")
git.inserts = tonumber(line:match("(%d+) ins")) or 0
git.deletes = tonumber(line:match("(%d+) del")) or 0