Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add recursive directory check for --restrict-file-list #4972

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions server/events/project_command_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would hide this behind a flag to make sure people that want to be very strict can still do so.

Copy link
Author

@ibalat ibalat Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so should we bind this logic to another parameter like --restrict-file-list-recursive ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibalat, yeah, that looks like a good flag to me. Just be aware that I can review this, but I'm not sure I'm the best person to give a final word if this should be accepted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree with @Fabianoshz. Introducing that flag could help to backwards compatibility 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey, thanks for your comments. I'll update the pr

foundDir = true
break
}
}

Expand All @@ -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
}
}

Expand Down