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

Commit 928407b

Browse files
committed
Merge pull request #63 from Strech/git-command-inside-root-dir
Git commands executes in root directory
2 parents 0de6eda + b32798d commit 928407b

File tree

1 file changed

+16
-3
lines changed
  • lib/code_climate/test_reporter

1 file changed

+16
-3
lines changed

lib/code_climate/test_reporter/git.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Git
55
class << self
66
def info
77
{
8-
head: `git log -1 --pretty=format:'%H'`,
8+
head: head,
99
committed_at: committed_at,
1010
branch: branch_from_git,
1111
}
@@ -31,15 +31,28 @@ def clean_git_branch
3131

3232
private
3333

34+
def head
35+
git("log -1 --pretty=format:'%H'")
36+
end
37+
3438
def committed_at
35-
committed_at = `git log -1 --pretty=format:%ct`
39+
committed_at = git('log -1 --pretty=format:%ct')
3640
committed_at.to_i.zero? ? nil : committed_at.to_i
3741
end
3842

3943
def branch_from_git
40-
`git rev-parse --abbrev-ref HEAD`.chomp
44+
git('rev-parse --abbrev-ref HEAD').chomp
45+
end
46+
47+
def git(command)
48+
`git --git-dir=#{git_dir}/.git #{command}`
49+
end
50+
51+
def git_dir
52+
defined?(Rails) ? Rails.root : '.'
4153
end
4254
end
4355
end
4456
end
4557
end
58+

0 commit comments

Comments
 (0)