File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 9
9
local function buildEscapedPattern (rawPattern )
10
10
-- Escape Lua pattern special characters except *
11
11
local escaped = string.gsub (rawPattern , " ([%-%+%?%(%)])" , " %%%1" )
12
- -- Convert * to match any character except /
12
+
13
+ -- Handle ** first (before single *) - use placeholder to avoid conflicts
14
+ escaped = string.gsub (escaped , " %*%*" , " __DOUBLESTAR__" )
15
+
16
+ -- Convert remaining * to match any character except /
13
17
escaped = string.gsub (escaped , " %*" , " [^/]*" )
14
18
19
+ -- Replace placeholder with pattern that matches any path including /
20
+ escaped = string.gsub (escaped , " __DOUBLESTAR__" , " .*" )
21
+
22
+ -- Special handling for **/name patterns - they should match directories
23
+ if string.match (rawPattern , " %*%*/[^/]+$" ) then
24
+ -- **/logs should match files within logs directories
25
+ escaped = escaped .. " /"
26
+ end
27
+
15
28
-- Handle trailing slash - directory patterns should match everything within
16
29
if string.match (escaped , " /$" ) then
17
30
-- Remove trailing slash and match anything that starts with this path
Original file line number Diff line number Diff line change @@ -256,4 +256,19 @@ function TestCO:testRootScriptsDirectoryPattern() -- luacheck: ignore 212
256
256
lu .assertEquals (result , {" @doctocat" , " @octocat" })
257
257
end
258
258
259
+ function TestCO :testDoubleStarLogsPattern () -- luacheck: ignore 212
260
+ -- Test **/logs pattern matches any logs directory at any depth
261
+ self .FS .openCodeownersFileAsLines = function ()
262
+ local lines = {" **/logs @octocat" }
263
+ local i = 0
264
+ return function ()
265
+ i = i + 1
266
+ return lines [i ]
267
+ end
268
+ end
269
+
270
+ local result = CO .matchFilesToCodeowner ({" build/logs/error.log" , " app/server/logs/access.log" , " logs/debug.log" })
271
+ lu .assertEquals (result , {" @octocat" })
272
+ end
273
+
259
274
os.exit (lu .LuaUnit .run ())
You can’t perform that action at this time.
0 commit comments