Skip to content

Conversation

splattael
Copy link
Contributor

@splattael splattael commented Jul 5, 2023

Using String filters can include wrong files to groups because it matches if the string is contained within the path.

For example:

  # This matches files like `./lib/foo.rb`
  # but also `./app/models/library.rb'
  add_group 'Libraries', 'lib'

  # Prefer Regexp filter instead:
  add_group 'Libraries', %r{^/lib/}

See also https://gitlab.com/gitlab-org/gitlab/-/issues/416910

Alternative

Instead, we could adjust the String filter to use start_with? instead of include? but that'd be a breaking change and also require users to prepend a leading slash to their configuration like:

  # Before
  add_group 'Libraries', 'lib'

  # After
  add_group 'Libraries', '/lib'

@splattael
Copy link
Contributor Author

This is somewhat related to #1016.

👋 @amatsuda If you have, do you mind reviewing this MR? 🙏

Using String filters can include wrong files to groups because it
matches if the string is contained within the path.

For example:

  # This matches files like `./lib/foo.rb`
  # but also `./app/models/library.rb'
  add_group 'Libraries', 'lib'

  # Prefer Regexp filter instead:
  add_group 'Libraries', %r{^/lib/}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant