Skip to content

Add method for sectional processing of CODEOWNERS

Kerri Miller requested to merge 215190-parse-codeowners-file-by-section into master

What does this MR do?

This code is behind a disabled feature flag

Building on !30311 (merged), this adds an initial cut at adding an additional step to our parsing of CODEOWNERS files, by looking for sectional headers and in the return hash, sorting pattern/entry by section. Thus, this CODEOWNERS file:

ee/ @gl-admin

[Documentation]
ee/docs    @gl-docs
docs       @gl-docs

[Database]
README.md  @gl-database
model/db   @gl-database

[Documentation]
README.md  @gl-docs

...results in this data structure:

{"codeowners"=>
  {"/**/ee/**/*"=>
    #<Gitlab::CodeOwners::Entry:0x00007fce678b2648
     @data=#<struct Gitlab::CodeOwners::Entry::Data pattern="ee/", owner_line="@gl-admin", section="codeowners">>},
 "documentation"=>
  {"/**/ee/docs"=>
    #<Gitlab::CodeOwners::Entry:0x00007fce678b2148
     @data=#<struct Gitlab::CodeOwners::Entry::Data pattern="ee/docs", owner_line="@gl-docs", section="documentation">>,
   "/**/docs"=>
    #<Gitlab::CodeOwners::Entry:0x00007fce678b1f18
     @data=#<struct Gitlab::CodeOwners::Entry::Data pattern="docs", owner_line="@gl-docs", section="documentation">>,
   "/**/README.md"=>
    #<Gitlab::CodeOwners::Entry:0x00007fce678b16f8
     @data=#<struct Gitlab::CodeOwners::Entry::Data pattern="README.md", owner_line="@gl-docs", section="documentation">>},
 "database"=>
  {"/**/README.md"=>
    #<Gitlab::CodeOwners::Entry:0x00007fce678b1bf8
     @data=#<struct Gitlab::CodeOwners::Entry::Data pattern="README.md", owner_line="@gl-database", section="database">>,
   "/**/model/db"=>
    #<Gitlab::CodeOwners::Entry:0x00007fce678b19c8
     @data=#<struct Gitlab::CodeOwners::Entry::Data pattern="model/db", owner_line="@gl-database", section="database">>}}

Related to #12137 (closed) and #215190 (closed)

Edited by Yorick Peterse

Merge request reports