Limit filename size in GitGuardian client
Problem
GitGuardian has a limit of 256 characters for filename.See GitGuardian API doc.
We want to make sure that the filename we send out to the API is less than the limit.
Proposal
In Gitlab::GitGuardian::Client
- Make a class constant
FILENAME_LIMIT
- Make a private method to shorten the string from the start of the string because we need the file extension for policies. Something like:
def limited_filename(filename)
filename_size = filename.length
over_limit = filename.length - FILENAME_LIMIT
return filename if over_limit <= 0
filename[over_limit..filename_size]
end