Skip to content

Commit

Permalink
Dedup files (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngan authored Nov 6, 2024
1 parent 7d62389 commit 11bc101
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
code_manifest (1.8.0)
code_manifest (1.9.0)
psych (>= 4.0.0)

GEM
Expand Down Expand Up @@ -50,4 +50,4 @@ DEPENDENCIES
rspec

BUNDLED WITH
2.5.4
2.5.23
2 changes: 1 addition & 1 deletion lib/code_manifest/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(patterns)

def files
@files ||= begin
matched_files = matches(Dir.glob(inclusion_rules.map(&:glob), GLOB_OPTIONS, base: CodeManifest.root))
matched_files = matches(Dir.glob(inclusion_rules.map(&:glob), GLOB_OPTIONS, base: CodeManifest.root)).uniq
files_with_relative_path(matched_files).freeze
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/code_manifest/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module CodeManifest
VERSION = '1.8.0'
VERSION = '1.9.0'
end
8 changes: 8 additions & 0 deletions spec/lib/code_manifest/manifest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
expect(manifest.files).to match_array(['bar/include', 'foo/foo.md'])
end

context 'when there are duplicate patterns' do
let(:patterns) { ['/foo/foo.md', 'bar/*', '!bar/exclude', 'bar/*'] }

it 'dedups files' do
expect(manifest.files).to match_array(['bar/include', 'foo/foo.md'])
end
end

context 'with different type of globs' do
let(:patterns) { ['dir_bar/**/*'] }
let(:manifest) { described_class.new(patterns) }
Expand Down

0 comments on commit 11bc101

Please sign in to comment.