CODEOWNER display is inconsistent on file/dir view

Summary

Customer reported that Code owners display the codeowner at the top of the file in an inconsistent way.

  • When an owner is assigned to a directory, using /, code owner will not display, or the parent directory owner will be display.
  • When viewing a directory, only when viewing the files.
  • When an owner is assigned to a directory without /, code owner will only display when viewing the directory
  • When viewing the files, no codeowner will be display, or parent directory owner will be display.

In order to display both for the files and the directory a double entry needs to be added one for the directory with / and one without /

Steps to reproduce

  1. Create a CODEOWNER file in any project
  2. Add an entry such as directory_1/ @user
  3. Add an entry such as directory_2 @otheruesr
  4. When you view directory_1 no codeowner will be display, or the parent directory owner will be display
  5. When view files in directory_1 , @user` will be display as codeowner
  6. When you view directory_2 @otheruser will be display as codeowner
  7. When view files in directory_2 no codeowner will be display, or the parent directory owner will be display

Example Project

https://gitlab.com/gitlab-gold/ggutierrez/issues3/codeowner-component

What is the current bug behavior?

When an owner is assigned to a directory, using /, code owner will not display for the directory, or the parent directory owner will be display.

What is the expected correct behavior?

When an owner is assigned to a directory, using /, on the directory view the owner of that directory should be display, not empty or the parent directory owner.

Relevant logs and/or screenshots

For the codoeowner entry Only_file_entrie @ggdtest this is the view Screen_Shot_2022-12-07_at_15.20.16

For the codeowner entry Only_directory_entrie/ @ggdtest this is the view Screen_Shot_2022-12-07_at_15.21.20

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Add two entries to CODEOWNER file, one with / and one without / to display the right owner at directory level and file level

Both_Codeowners_entries @ggdcc
Both_Codeowners_entries/ @ggdcc
Edited by 🤖 GitLab Bot 🤖