-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with "files have unique owners" validation (#31)
* Add failing test * Fix failing test * Bump version * Fix non-determinism in output so CI passes
- Loading branch information
Alex Evanczuk
authored
Feb 22, 2023
1 parent
b4fb864
commit 8913407
Showing
6 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
code_ownership (1.29.3) | ||
code_ownership (1.30.0) | ||
code_teams (~> 1.0) | ||
packs | ||
sorbet-runtime | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Gem::Specification.new do |spec| | ||
spec.name = "code_ownership" | ||
spec.version = '1.29.3' | ||
spec.version = '1.30.0' | ||
spec.authors = ['Gusto Engineers'] | ||
spec.email = ['[email protected]'] | ||
spec.summary = 'A gem to help engineering teams declare ownership of code' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
lib/code_ownership/private/validations/no_overlapping_globs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# typed: strict | ||
|
||
module CodeOwnership | ||
module Private | ||
module Validations | ||
class NoOverlappingGlobs | ||
extend T::Sig | ||
extend T::Helpers | ||
include Interface | ||
|
||
sig { override.params(files: T::Array[String], autocorrect: T::Boolean, stage_changes: T::Boolean).returns(T::Array[String]) } | ||
def validation_errors(files:, autocorrect: true, stage_changes: true) | ||
overlapping_globs = OwnershipMappers::TeamGlobs.new.find_overlapping_globs | ||
|
||
errors = T.let([], T::Array[String]) | ||
|
||
if overlapping_globs.any? | ||
errors << <<~MSG | ||
`owned_globs` cannot overlap between teams. The following globs overlap: | ||
#{overlapping_globs.map { |overlap| "- #{overlap.description}"}.join("\n")} | ||
MSG | ||
end | ||
|
||
errors | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters