@@ -2,59 +2,6 @@ local git = {} -- circular dependencies
2
2
3
3
local M = {}
4
4
5
- --- @class GitStatus
6
- --- @field file string | nil
7
- --- @field dir table | nil
8
-
9
- --- @param parent_ignored boolean
10
- --- @param status table | nil
11
- --- @param absolute_path string
12
- --- @return GitStatus | nil
13
- local function get_dir_git_status (parent_ignored , status , absolute_path )
14
- if parent_ignored then
15
- return { file = " !!" }
16
- end
17
-
18
- if status then
19
- return {
20
- file = status .files and status .files [absolute_path ],
21
- dir = status .dirs and {
22
- direct = status .dirs .direct [absolute_path ],
23
- indirect = status .dirs .indirect [absolute_path ],
24
- },
25
- }
26
- end
27
- end
28
-
29
- --- @param parent_ignored boolean
30
- --- @param status table
31
- --- @param absolute_path string
32
- --- @return GitStatus
33
- local function get_git_status (parent_ignored , status , absolute_path )
34
- local file_status = parent_ignored and " !!" or (status and status .files and status .files [absolute_path ])
35
- return { file = file_status }
36
- end
37
-
38
- --- @param node Node
39
- --- @param parent_ignored boolean
40
- --- @param status table | nil
41
- function M .update_git_status (node , parent_ignored , status )
42
- local get_status
43
- if node .nodes then
44
- get_status = get_dir_git_status
45
- else
46
- get_status = get_git_status
47
- end
48
-
49
- -- status of the node's absolute path
50
- node .git_status = get_status (parent_ignored , status , node .absolute_path )
51
-
52
- -- status of the link target, if the link itself is not dirty
53
- if node .link_to and not node .git_status then
54
- node .git_status = get_status (parent_ignored , status , node .link_to )
55
- end
56
- end
57
-
58
5
--- @param node Node
59
6
--- @return GitStatus | nil
60
7
function M .get_git_status (node )
@@ -128,7 +75,7 @@ function M.reload_node_status(parent_node, projects)
128
75
local toplevel = git .get_toplevel (parent_node .absolute_path )
129
76
local status = projects [toplevel ] or {}
130
77
for _ , node in ipairs (parent_node .nodes ) do
131
- M . update_git_status (node , M .is_git_ignored (parent_node ), status )
78
+ node : update_git_status (M .is_git_ignored (parent_node ), status )
132
79
if node .nodes and # node .nodes > 0 then
133
80
M .reload_node_status (node , projects )
134
81
end
0 commit comments