Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Feature: Cleanup command #80

Open
dennissivia opened this issue May 25, 2020 · 3 comments
Open

Feature: Cleanup command #80

dennissivia opened this issue May 25, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@dennissivia
Copy link

After some discussion I am suggesting to add a cleanup command to tackle the following problems:

Problem

When a CODEOWNERS file becomes bigger the following problems arise:

  • Duplicate patterns
  • Hard to find what belongs to the same owner (lack of sorting)
  • Obsolete patterns (no file matches the given pattern)

Proposal

Add a new command --cleanup to do the following things.

  • Sort the file based on the rules listed below (See sorting
  • Remove duplicate patterns (only full duplications)
  • Expand each pattern and if finds 0 files, remove the pattern

Sorting

Our initial discussion lead to the following proposal:

  • Sort (and thus group) by owner
  • Within one owner sort patterns alphabetically

Related issues

#21 also asks for some of these topics.

@dennissivia dennissivia added the enhancement New feature or request label May 25, 2020
@bamorim
Copy link
Contributor

bamorim commented Jun 3, 2020

Hi, I'm tackling this issue right now but I'd like to discuss about the sorting thing.

When generating the new CODEOWNERS file after sorting, should we keep the comments?

Comments right now are being treated as part of the "syntax" because of the "grouping" feature. I'm afraid it may be hard to keep comments and still order by the owner.

My idea was to simply start a new codeowners file from scratch and just "group" with the name of the owner, like such

# Owned by @owner_a
file_b @owner_a
file_c @owner_a

# Owned by @owner_b
file_a @owner_b

Any suggestions on how to do this in a simple way?

@bamorim
Copy link
Contributor

bamorim commented Jun 3, 2020

Also, how should we handle patterns with multiple owners?

The only reasonably solution is to treat a collection of owners as a "unique owner" when grouping

Something like

# Owned by @owner_a and @owner_b
file_d @owner_a @owner_b

# Owned by @owner_a
file_b @owner_a
file_c @owner_a

# Owned by @owner_b
file_a @owner_b

But we still need to think how to sort them.

@bamorim bamorim mentioned this issue Jun 3, 2020
3 tasks
@bamorim
Copy link
Contributor

bamorim commented Jun 3, 2020

Another question: should we check for consistency on this command as well? Or just rewrite the file?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants