Fix gitattributes parser to apply patterns to subdirectories

What does this MR do and why?

Contributes to #513617 (closed)

Problem

Patterns like Dockerfile.* are currently applied only to the root directory of the repository.

  • Dockerfile.local - match
  • docker/Dockerfile.local - no match

However, it's incorrect. Git captures both file paths as matches. So GitLab should follow the same logic.

Solution

Use File::FNM_PATHNAME to support glob pattern matching.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After (FROM is highlighted)
Screenshot_2025-01-20_at_14.26.16 Screenshot_2025-01-20_at_14.27.18

How to set up and validate locally

  1. Enable feature flag Feature.enable(:attribute_parser_fix)
  2. Clone an example project (or recreate it locally): https://gitlab.com/iamthad/gitattributes-bug-repro
  3. Visit https://<path_to_project_in_gdk>/-/blob/main/docker/Dockerfile.local?ref_type=heads
  4. The code should be highlighted
Edited by Vasilii Iakliushin

Merge request reports

Loading