Class: Codacy::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/codacy/git.rb

Class Method Summary collapse

Class Method Details

.commit_idObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/codacy/git.rb', line 3

def self.commit_id

  commit = ENV['TRAVIS_COMMIT'] ||
      ENV['DRONE_COMMIT'] ||
      ENV['GIT_COMMIT'] ||
      ENV['CIRCLE_SHA1'] ||
      ENV['CI_COMMIT_ID'] ||
      ENV['WERCKER_GIT_COMMIT'] ||
      git_commit

  commit
end

.git(command) ⇒ Object



29
30
31
# File 'lib/codacy/git.rb', line 29

def self.git(command)
  `git --git-dir="#{git_dir}/.git" #{command}`
end

.git_commitObject



21
22
23
# File 'lib/codacy/git.rb', line 21

def self.git_commit
  git("log -1 --pretty=format:'%H'")
end

.git_dirObject



25
26
27
# File 'lib/codacy/git.rb', line 25

def self.git_dir
  return `git rev-parse --show-toplevel`.strip!
end

.work_dirObject



16
17
18
19
# File 'lib/codacy/git.rb', line 16

def self.work_dir
  work_dir = ENV['WORK_DIR'] || git_dir
  work_dir
end