Skip to content

Commit

Permalink
don't associate a file with a different package that matches a prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
exterm committed Mar 19, 2024
1 parent f52fb63 commit 133619a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/packwerk/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def dependency?(package)
def package_path?(path)
return true if root?

path.start_with?(@name)
path.start_with?(@name + "/")
end

sig { params(other: T.untyped).returns(T.nilable(Integer)) }
Expand Down
4 changes: 4 additions & 0 deletions test/unit/packwerk/package_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class PackageTest < Minitest::Test
assert_equal(true, root_package.package_path?("components/unknown"))
end

test "#package_path? returns false for different path with matching prefix" do
assert_equal(false, @package.package_path?("components/timeline_ui/something.rb"))
end

test "#<=> compares against name" do
assert_equal(-1, @package <=> Package.new(name: "components/xyz", config: {}))
assert_equal(0, @package <=> Package.new(name: "components/timeline", config: {}))
Expand Down

0 comments on commit 133619a

Please sign in to comment.