Skip to content

Commit 2d58507

Browse files
committed
Filter out non-files.
1 parent 3a3b7f3 commit 2d58507

File tree

3 files changed

+307
-2
lines changed

3 files changed

+307
-2
lines changed

lib/nanoc/github.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ def decode(content)
2929
def repository_items
3030
client
3131
.contents(repository, path: path)
32-
.map { |item| client.contents(repository, path: item[:path]) }
33-
rescue Octokit::NotFound => exc
32+
.select { |item| item[:type] == "file" }
33+
.map { |item| client.contents(repository, path: item[:path]) }
34+
rescue Octokit::NotFound => exc
3435
[]
3536
end
3637

test/fixtures/test_items_in_root.yml

Lines changed: 291 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/source_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def empty_source_by_path
2727
})
2828
end
2929

30+
def flat_source
31+
Source.new(site_config, nil, nil, {
32+
repository: "pawelpacana/test-source",
33+
})
34+
end
35+
3036
def test_identifier
3137
assert_equal :github, source_with_posts.class.identifier
3238
end
@@ -52,6 +58,13 @@ def test_no_items_in_path
5258
end
5359
end
5460

61+
def test_items_in_root
62+
VCR.use_cassette("test_items_in_root") do
63+
assert_kind_of Array, flat_source.items
64+
refute flat_source.items.empty?
65+
end
66+
end
67+
5568
def test_item
5669
VCR.use_cassette("test_item") do
5770
item = source_with_posts.items[0]

0 commit comments

Comments
 (0)