Option to return unsorted Codeowners
mweirauch opened this issue · 3 comments
Motivation
We are operating a historically grown monorepo where some of the modules are of shared nature. Thus, some modules contain multiple approvers in a CODEOWNERS entry. Nevertheless, the first in the list is still somewhat considered the "main" owner. (As irritating as that might sound.)
[SomeSection]
/module-a/ @foo @bar
/module-b/ @foo @baz
For both of these path specifications @foo
is not the first item in the list retrieved with ::getAllApprovers
.
Challenge
The CodeOwners
implementation does some sorted()
calls on the approver streams. I think the "challenging" location is in ::visitApprovalRule
.
Would it be feasible to introduce some unsortedApprovers
property which could be a tunable like verbose
? Then the sorted()
calls could take a Comparator
which behaves according to the unsortedApprovers
property either always returning 0
or perform the string-natural sort as is the default with sorted()
.
PS: Thanks for this library!
I had a look how hard this is; doable.
Looks like simply maintaining the ordering as present in the source file is the easiest.
Also there are some edge cases with multiple rules in multiple sections and the fact you can add more rules to a section later in the file.
I'm going for the best possible maintaining of ordering.
I will keep a deduplication in there so that a later entry of the same user is removed.
I have released 1.4.0 with this.
Please let me know what you think.
Sorry for the late reply. I missed the notification. It works like a charm!
Thank you very much!