hmarr / codeowners

🔒 Command line tool and Go library for CODEOWNERS files
MIT License
167 stars 19 forks source link

Error when codeowners file lists an empty owner #4

Closed fredefox closed 2 years ago

fredefox commented 2 years ago

According to https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners it is valid to have a line in CODEOWNERS where no owner is listed. This is interpreted as the file not being owned. Quoting from that link:

# In this example, @octocat owns any file in the `/apps` 
# directory in the root of your repository except for the `/apps/github` 
# subdirectory, as its owners are left empty.
/apps/ @octocat
/apps/github

codeowners currently doesn't handle this and in stead reports:

line 1: unexpected end of rule

I tried patching, but I'm not really a proficient in go sadly.

dudicoco commented 2 years ago

@fredefox, out of curiosity, why would you want files without an owner?

fredefox commented 2 years ago

Well. The issue is that if I come across a project with such a line in the code owners this program will fail. So it's not really a question of what I would or wouldn't like to have in a code owners file.

That aside there might be legitimate reasons for doing it. Perhaps you want to set a given owner for all files except in some subdirectory and let those be unspecified. This is what they do in the example from the documentation from GitHub.

dimitarvdimitrov commented 2 years ago

I'm happy to work on this in the coming week (or two)

hmarr commented 2 years ago

👋 @obukhov kindly took care of this. The fix is available in v0.4.0, which I just released.