Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CODEOWNERS feature #25060

Closed
wants to merge 41 commits into from
Closed

Add CODEOWNERS feature #25060

wants to merge 41 commits into from

Conversation

bcallaghan-et
Copy link

Adds the ability to define code ownership in a CODEOWNERS file, similar to the GitHub feature. See the new docs page for a full feature description.

Closes #10161

Implementation

The primary back-end change is adding a call to AddCodeownerReviewers() in services/issue/issue.go. This searches the base repo for a valid CODEOWNERS file, parses it, and requests reviews from any users/teams that own any changed files in the PR. The parsing/validation is contained in functions within services/issue/codeowners.go.

The applicable CODEOWNERS file is also parsed to:

  • Display validation errors when viewing/editing a CODEOWNERS file
  • Display the hoverable shield icon inticating ownership as described below

UI Changes

Viewing a CODEOWNERS file with validation errors:
Validation information on view

Editing a CODEOWNERS file with validation errors:
Validation information on edit

The remaining examples assume the following valid CODEOWNERS file is in the main branch:

asdf/ @user3 @Org1/teamA
*.txt @Org1/teamA

Viewing a file that has an owner displays a shield icon that can be hovered over to show the ownership tooltip. If no owner applies to the file, the shield is not displayed:
Shield when viewing a file

When opening a PR, the same hoverable codeowner shield icon is visible for any changed files with owners:
Shields when creating pull request

Same thing when viewing a PR's changed files:
Shields when viewing PR changed files

Same thing when viewing a commit:
Shields when a commit

Known issues and features we are still working on

  • Testing. We recently ran into some issues integrating our unit tests properly.
  • Currently anyone can create/edit a CODEOWNERS file. This needs to be restricted to users with admin/owner permissions to match the GitHub feature.
  • Codeowners should not be added when a PR is created as WIP, but should then be added when the WIP prefix is removed.
  • Some code can be cleaned up and refactored a bit in codeowners.go

smoffat-et and others added 30 commits May 23, 2023 15:55
Users that exist are automatically requested as reviewers when a PR is created. Does not work for teams. Does not validate that the users are eligible to actually review the PR. Includes call to stub function in issue.go (line 216) to what will become the Parser.
Returns a list of individual owners and teams associated with changed files that are passed into it.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 2, 2023
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 2, 2023
@yardenshoham
Copy link
Member

Duplicate of #24910?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should just set FileError. This is already implemented in Gitea, so you don't need this file.

@smophat7
Copy link

smophat7 commented Jun 3, 2023

Duplicate of #24910?

Yeah. This one follows the GitHub CODEOWNERS syntax rules though, and it requires write access to be an owner. Shield icon on the files is helpful.

@lunny
Copy link
Member

lunny commented Nov 7, 2023

Since #24910 merged, please update this PR.

@bcallaghan-et
Copy link
Author

It's been a while since anyone on my team has looked at this. If any further changes are required to the CODEOWNERS feature (in either our implementation or the official implementation), it would be easier for all parties to create a new issue and work fresh from the latest version of Gitea.

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support Github-like CODEOWNERS?
8 participants