@@ -53,14 +53,14 @@ local function new_counter()
5353 end )
5454end
5555
56- local function call_proc (process , args , cwd , cb )
56+ local function call_proc (process , args , cwd , cb , print_stdout )
5757 local log = uv .fs_open (LOGFILE , " a+" , 0x1A4 )
5858 local stderr = uv .new_pipe (false )
5959 stderr :open (log )
6060 local handle , pid
6161 handle , pid = uv .spawn (
6262 process ,
63- { args = args , cwd = cwd , stdio = { nil , nil , stderr }, env = env },
63+ { args = args , cwd = cwd , stdio = { nil , print_stdout and stderr , stderr }, env = env },
6464 vim .schedule_wrap (function (code )
6565 uv .fs_close (log )
6666 stderr :close ()
@@ -73,6 +73,12 @@ local function call_proc(process, args, cwd, cb)
7373 end
7474end
7575
76+ local function log (message )
77+ local log = uv .fs_open (LOGFILE , " a+" , 0x1A4 )
78+ uv .fs_write (log , message .. ' \n ' )
79+ uv .fs_close (log )
80+ end
81+
7682local function run_hook (pkg , counter , sync )
7783 local t = type (pkg .run )
7884 if t == " function" then
@@ -125,15 +131,20 @@ local function get_git_hash(dir)
125131end
126132
127133local function pull (pkg , counter , sync )
128- local hash = get_git_hash (pkg .dir )
134+ local prev_hash = get_git_hash (pkg .dir )
129135 call_proc (" git" , { " pull" , " --recurse-submodules" , " --update-shallow" }, pkg .dir , function (ok )
130136 if not ok then
131137 counter (pkg .name , " err" , sync )
132- elseif get_git_hash (pkg .dir ) ~= hash then
133- pkg .status = " updated"
134- return pkg .run and run_hook (pkg , counter , sync ) or counter (pkg .name , " ok" , sync )
135138 else
136- counter (pkg .name , " nop" , sync )
139+ local cur_hash = get_git_hash (pkg .dir )
140+ if cur_hash ~= prev_hash then
141+ log (pkg .name .. " updating..." )
142+ call_proc (" git" , { " log" , " --pretty=format:* %s" , prev_hash .. " .." .. cur_hash }, pkg .dir , function (ok ) end , true )
143+ pkg .status = " updated"
144+ return pkg .run and run_hook (pkg , counter , sync ) or counter (pkg .name , " ok" , sync )
145+ else
146+ counter (pkg .name , " nop" , sync )
147+ end
137148 end
138149 end )
139150end
0 commit comments