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

README: Recommend using Regexp filters for add_group #1062

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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'

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.

None yet

1 participant