Sha256: f4b49370f145d65b24eab6aa139548e4c93c126a9790463d811f38cc1f517194

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 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'] ||
          ENV['HEROKU_TEST_RUN_COMMIT_VERSION'] ||
          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

2 entries across 2 versions & 1 rubygems

Version Path
codacy-coverage-2.0.1 lib/codacy/git.rb
codacy-coverage-2.0.0 lib/codacy/git.rb