Skip to content

Commit c22c123

Browse files
committed
Skip .gitignore if it's a directory.
IncludePathsBuilder was erroring on repos where .gitignore was a directory (most likely due to developer error). Now it just skips .gitignore instead.
1 parent 729a973 commit c22c123

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/cc/analyzer/include_paths_builder.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def filter_by_cc_includes
4646

4747
def ignored_files
4848
Tempfile.open(".cc_gitignore") do |tmp|
49-
tmp.write(File.read(".gitignore")) if File.exist?(".gitignore")
49+
tmp.write(File.read(".gitignore")) if File.file?(".gitignore")
5050
tmp << @cc_exclude_paths.join("\n")
5151
tmp.close
5252
tracked_and_ignored = `git ls-files -zi -X #{tmp.path}`.split("\0")

spec/cc/analyzer/include_paths_builder_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,15 @@ module CC::Analyzer
243243
result.include?("untrackable.rb").must_equal(false)
244244
end
245245
end
246+
247+
describe "when .gitignore is a directory" do
248+
before do
249+
FileUtils.mkdir(".gitignore")
250+
end
251+
252+
it "skips it entirely" do
253+
result.include?("./").must_equal(true)
254+
end
255+
end
246256
end
247257
end

0 commit comments

Comments
 (0)