Skip to content

Fix JH Code Owner pattern

What does this MR do and why?

In In the previous MR !117020 (merged), we added some rules for JH.

Sorry there are some mistakes here:

If we want to match all rb files in the jh directory, it should be /jh/**/*.rb, not /jh/*.rb .

Screenshots or screen recordings

Non-UI

How to set up and validate locally

FNMATCH_FLAGS = (::File::FNM_DOTMATCH | ::File::FNM_PATHNAME).freeze
path = '/jh/app/models/jh/issue.rb'
file = Gitlab::CodeOwners::File.new


pattern = file.send(:normalize_pattern, '*') # "/**/*"
::File.fnmatch?(pattern, path, FNMATCH_FLAGS) # true


pattern = file.send(:normalize_pattern, '*.rb') # "/**/*.rb"
::File.fnmatch?(pattern, path, FNMATCH_FLAGS) # true


# Wrong
pattern = file.send(:normalize_pattern, '/jh/*.rb') # "/jh/*.rb"
::File.fnmatch?(pattern, path, FNMATCH_FLAGS) # false


# Correct
pattern = file.send(:normalize_pattern, '/jh/**/*.rb') # "/jh/**/*.rb"
::File.fnmatch?(pattern, path, FNMATCH_FLAGS) # true

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports