From aa83821a95557481160c654f34122dc28af65e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smet=20BALAT?= Date: Tue, 1 Oct 2024 13:20:07 +0300 Subject: [PATCH] feat: Add recursive directory check for --restrict-file-list --- server/events/project_command_builder.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 35e540a858..c1674aaaec 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -629,8 +629,10 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *command.Cont foundDir := false for _, f := range modifiedFiles { - if filepath.Dir(f) == cmd.RepoRelDir { + // Check if the file is in the directory or any subdirectory of the target + if strings.HasPrefix(filepath.Dir(f), cmd.RepoRelDir) { foundDir = true + break } } @@ -654,8 +656,10 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *command.Cont foundDir := false for _, p := range repoCfgProjects { - if filepath.Dir(f) == p.Dir { + // Check if the file is in the directory or any subdirectory of the project directory + if strings.HasPrefix(filepath.Dir(f), p.Dir) { foundDir = true + break } }