@@ -8,6 +8,7 @@ local renderer = require("neo-tree.ui.renderer")
8
8
local inputs = require (" neo-tree.ui.inputs" )
9
9
local events = require (" neo-tree.events" )
10
10
local log = require (" neo-tree.log" )
11
+ local fs_watch = require (" neo-tree.sources.filesystem.lib.fs_watch" )
11
12
12
13
local M = {}
13
14
local source_data = {}
@@ -324,4 +325,34 @@ M.show = function(source_name)
324
325
end
325
326
end
326
327
328
+ local known_dot_git_folders = {}
329
+ M .watch_git_project = function (source_name , path )
330
+ local state = M .get_state (source_name )
331
+ local root = utils .get_git_project_root (path )
332
+ if not utils .truthy (root ) then
333
+ return
334
+ end
335
+ dot_git = root .. utils .path_separator .. " .git"
336
+ if dot_git ~= state .git_folder then
337
+ log .debug (" Watching .git folder: " , dot_git )
338
+ if utils .truthy (state .git_folder ) then
339
+ fs_watch .unwatch_folder (state .git_folder )
340
+ end
341
+ fs_watch .watch_folder (dot_git )
342
+ state .git_folder = dot_git
343
+ if # known_dot_git_folders == 0 then
344
+ events .subscribe ({
345
+ event = events .FS_EVENT ,
346
+ handler = function (args )
347
+ local is_git_root = known_dot_git_folders [args .path ]
348
+ if is_git_root then
349
+ events .fire_event (events .GIT_EVENT , args )
350
+ end
351
+ end ,
352
+ })
353
+ end
354
+ known_dot_git_folders [dot_git ] = true
355
+ end
356
+ end
357
+
327
358
return M
0 commit comments