[Step1|BE] Change git check access to allow multiple files
Important: All the new functionality must be implemented behind the feature flag :snippet_multiple_files
. Besides, it has to be scoped for users. Therefore, instead of checking if the feature flag is enabled or not (Feature.enabled?(:snippet_multiple_files)
), we will check if the feature flag is enabled for specific users (Feature.enabled?(:snippet_multiple_files, user)
).
For the MVP we limited the number of files that can be present in the repository to 1. Now that we're allowing multiple files, we have to raise that limit to 10 files.
We need to update the constant MAX_FILE_COUNT
to 10. Because constants are loaded and cannot be changed in staging or prod, we need to create a method (with a user as the argument) that will be the one checking the feature flag and returning the proper value.
It will be basically a matter of:
class Snippet
MAX_FILE_COUNT = 1
NEW_MAX_FILE_COUNT = 10
def max_file_count(user)
Feature.enabled?(:snippet_multiple_files, user) ? NEW_MAX_FILE_COUNT : MAX_FILE_COUNT
end
end
we need to update the call to the check Checks::PushFileCountCheck
inside Gitlab::GitAccessSnippet
to call this new method (passing the user) instead of calling the constant directly.
Once we remove the feature flag we can safely set MAX_FILE_COUNT
to the new limit and call the constant.
Testing Activity
- Check/update spec
spec/lib/gitlab/checks/push_file_count_check_spec.rb
- Check new method that returns the limit based on the feature flag
- Different tests in the specs for Gitlab::GitAccessSnippet to test the new behavior
@vij:
- Update existing test to cover support for multiple files
- API endpoints continue to work well with one file snippets (current coverage)
- API endpoints should return multi-file snippets as well
MR Breakdown
- 1 MR to adapt the constant and the related classes that use it along with the corresponding specs