Skip to content

Allow self-satisfaction of codeowner groups.#93

Merged
BakerNet merged 2 commits intomultimediallc:mainfrom
Icantjuddle:allow_self_own
Feb 18, 2026
Merged

Allow self-satisfaction of codeowner groups.#93
BakerNet merged 2 commits intomultimediallc:mainfrom
Icantjuddle:allow_self_own

Conversation

@Icantjuddle
Copy link
Contributor

Summary / Background

It is useful to be able to allow self-satisfaction of codeowner groups.
i.e. if COs for some files are alice and bob, bob is allowed to push code without alices specific approval since he is an owner of the code.

Implements via a config item to allow "self approval".

In code I add a new authorMode that determines how authors are handled by SetAuthor which can optionally satisfy groups they're part of.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Icantjuddle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature that allows pull request authors to automatically satisfy codeowner groups they are part of. Previously, even if an author was a codeowner for a file, another member of that group would still need to approve the change. With the new 'allow_self_approval' configuration, authors can now implicitly approve their own changes for files where they are listed in an OR ownership group, streamlining the review process for internal contributions.

Highlights

  • New Configuration Option: Introduced a new configuration option, 'allow_self_approval', in 'codeowners.toml' to enable or disable the self-satisfaction of codeowner groups.
  • Enhanced Author Processing: Modified the 'SetAuthor' function across the codebase to accept an 'AuthorMode' parameter, allowing for different behaviors when processing the PR author.
  • Self-Approval Logic: Implemented 'AuthorModeSelfApproval' logic, which automatically satisfies any OR ownership group an author belongs to if 'allow_self_approval' is enabled.
  • Comprehensive Testing: Added comprehensive unit tests to validate the new self-approval functionality, covering various scenarios including multi-member OR groups, multiple OR groups, and case-insensitivity.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • codeowners.toml
    • Added 'allow_self_approval' configuration option with a default value of 'false'.
  • internal/app/app.go
    • Updated the call to 'codeOwners.SetAuthor' to pass the newly introduced 'AuthorMode', determined by the 'AllowSelfApproval' configuration.
  • internal/app/app_test.go
    • Modified the 'mockCodeOwners.SetAuthor' method signature to include the 'AuthorMode' parameter.
    • Adjusted the logic within 'SetAuthor' to mark a reviewer group as approved if 'AuthorModeSelfApproval' is active and the group becomes empty or the author is part of it.
  • internal/config/config.go
    • Added 'AllowSelfApproval' boolean field to the 'Config' struct, enabling its parsing from the TOML configuration.
  • internal/config/config_test.go
    • Added a new test case to verify the correct parsing of the 'allow_self_approval' configuration from a TOML file.
    • Extended an existing test to check the 'AllowSelfApproval' field during configuration loading.
  • pkg/codeowners/codeowners.go
    • Introduced 'AuthorMode' enum with 'AuthorModeDefault' and 'AuthorModeSelfApproval' values.
    • Updated the 'CodeOwners' interface and the 'ownersMap' implementation of 'SetAuthor' to accept the new 'AuthorMode' parameter.
    • Modified the 'ownersMap.SetAuthor' logic to apply self-approval based on the provided 'AuthorMode'.
  • pkg/codeowners/codeowners_test.go
    • Updated existing calls to 'owners.SetAuthor' to explicitly pass 'AuthorModeDefault'.
    • Added several new test functions to thoroughly test the self-approval logic under various conditions.
  • pkg/codeowners/merger_test.go
    • Updated the 'merged.SetAuthor' call to use 'AuthorModeDefault'.
    • Added 'TestMergeCodeOwnersSetAuthorSelfApproval' to test self-approval behavior when merging codeowners from different branches.
  • tools/cli/main_test.go
    • Updated the 'fakeCodeOwners.SetAuthor' method signature to match the new 'AuthorMode' parameter.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a useful feature for allowing self-satisfaction of codeowner groups, controlled by a new allow_self_approval configuration option. The implementation adds a new AuthorMode to handle the logic within SetAuthor. The changes are well-tested at the package level with comprehensive new test cases. However, I've identified a significant issue in a mock implementation in internal/app/app_test.go which prevents the new self-approval logic from being tested at the application level. This should be addressed to ensure full test coverage for the new feature.

Copy link
Collaborator

@BakerNet BakerNet left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I can see why this feature would be desired by some teams so I'm good with this going in.

Would you mind copying the codeowners.toml text over to the README and then run ./scripts/covbadge.sh before commit?

@BakerNet BakerNet merged commit c6a44b9 into multimediallc:main Feb 18, 2026
3 of 6 checks passed
@Icantjuddle
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants