Codeowners file doesn't support absolute paths #12038

Open
opened 2025-11-02 09:55:45 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @otbutz on GitHub (Nov 17, 2023).

Description

The codeowners support #10161 introduced in https://github.com/go-gitea/gitea/pull/24910 doesn't seem to support paths starting with /:

# works
docs/*.\\.md
# doesn't
/docs/*.\\.md

This is supported by Githubs syntax: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file

I thought it might be supported by gitea as well because of this example provided in the documentation:

!/assets/.*\\.(bin|exe|msi) @user9

Gitea Version

1.21.0

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Binary started via systemd behind a caddy reverse proxy.

Database

None

Originally created by @otbutz on GitHub (Nov 17, 2023). ### Description The codeowners support #10161 introduced in https://github.com/go-gitea/gitea/pull/24910 doesn't seem to support paths starting with `/`: ``` # works docs/*.\\.md # doesn't /docs/*.\\.md ``` This is supported by Githubs syntax: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#example-of-a-codeowners-file I thought it might be supported by gitea as well because of this example provided in the documentation: ``` !/assets/.*\\.(bin|exe|msi) @user9 ``` ### Gitea Version 1.21.0 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Binary started via systemd behind a caddy reverse proxy. ### Database None
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 09:55:45 -06:00
Author
Owner

@yp05327 commented on GitHub (Mar 21, 2024):

First, I think your example should be:

# works
docs/.*\\.md
# doesn't
/docs/.*\\.md

We get the changed files path by diff-tree which will not contain / ahead of the path.
So the sample you provided is actually not supported yet.

!/assets/.*\\.(bin|exe|msi) @user9

This one works because it has ! which means it is a negative rule, and regexp match will always be false, so it worked. But it is not correct, so without !, it won't work.
image
↑ the condition

@yp05327 commented on GitHub (Mar 21, 2024): First, I think your example should be: ``` # works docs/.*\\.md # doesn't /docs/.*\\.md ``` We get the changed files path by `diff-tree` which will not contain `/` ahead of the path. So the sample you provided is actually not supported yet. ``` !/assets/.*\\.(bin|exe|msi) @user9 ``` This one works because it has `!` which means it is a negative rule, and regexp match will always be false, so it worked. But it is not correct, so without `!`, it won't work. ![image](https://github.com/go-gitea/gitea/assets/18380374/323963f6-de55-493c-b098-8dc3b117e8b2) ↑ the condition
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12038