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

Feature: collapse codeowners into directories when possible #98

Open
jpmcb opened this issue Aug 27, 2024 · 2 comments
Open

Feature: collapse codeowners into directories when possible #98

jpmcb opened this issue Aug 27, 2024 · 2 comments

Comments

@jpmcb
Copy link
Member

jpmcb commented Aug 27, 2024

Suggested solution

Right now, the code owners generation will granularly denote codeowners for each file in the git tree:

path/to/file1 @jpmcb
path/to/file2 @jpmcb
path/to/file3 @jpmcb

In this case, it makes sense to just collapse the directory to:

path/to/ @jpmcb

since all files under that tree are owned by that person. There are probably 1000 and 1 edge cases on this so it'll be critical to think through the data structures and the algorithms for how this would work. Likely, off the top of my head, we'd probably want to take a tree traversal approach where we go deep first over breadth.

@udaypatel1
Copy link
Contributor

Interesting feature!

I'll list an assumption:

  1. A directory is considered collapsable if all of its files have the same number and order of attributors

Collapsable

path/to/file1 @userA @userC
path/to/file2 @userA @userC
path/to/file3 @userA @userC

Not Collapsable

path/to/file1 @userA
path/to/file2 @userB @userC
path/to/file3 @userB @userA @userC

Thinking out loud, I can see 2 paths for potential implementation:

  1. Perform the directory collapse process during traversal and CODEOWNERS build time
  2. Perform the directory collapse process after traversal and when CODEOWNERS has been built

The latter of the two would be slightly simpler but require the generated CODEOWNERS file to be parsed which may be (algorithmically) less efficient.

Filtering and collapsing directories while generating the CODEOWNERS file would be ideal, but would increase the complexity of designing this feature.

@jpmcb
Copy link
Member Author

jpmcb commented Oct 21, 2024

Filtering and collapsing directories while generating the CODEOWNERS file would be ideal, but would increase the complexity of designing this feature.

It'd have to be after the file tree with its codeowners has been calculated: this is technically a graph traversal problem and you can't know which nodes to collapse unless you've visited all nodes. This comes with its own challenges sine the internal structure of how the codeowners is calculated isn't really built around this graph / tree idea (and it really should be).

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

No branches or pull requests

2 participants