Sha256: 1b715c6bcecb07f510fead7d67ec8d9f0760733f518fad65165f1262f5060d43

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

module Codacy
  class Git
    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

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

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

    def self.git_dir
      dir = `git rev-parse --show-toplevel`
      if $?.to_i == 0
        return dir.strip!
      else
        return ''
      end
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codacy-coverage-1.1.8 lib/codacy/git.rb
codacy-coverage-1.1.7 lib/codacy/git.rb
codacy-coverage-1.1.6 lib/codacy/git.rb