Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 2cb2c63

Browse files
committed
Check that the .git directory exists when Rails.root is defined.
1 parent 7e5951d commit 2cb2c63

File tree

1 file changed

+8
-1
lines changed
  • lib/code_climate/test_reporter

1 file changed

+8
-1
lines changed

lib/code_climate/test_reporter/git.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module CodeClimate
22
module TestReporter
33
class Git
4+
require "pathname"
45

56
class << self
67
def info
@@ -49,7 +50,13 @@ def git(command)
4950
end
5051

5152
def git_dir
52-
defined?(Rails) ? Rails.root : '.'
53+
root = "."
54+
55+
if defined?(Rails) && Pathname(Rails.root).expand_path(".git").directory?
56+
root = Rails.root
57+
end
58+
59+
root
5360
end
5461
end
5562
end

0 commit comments

Comments
 (0)