Sha256: ce33b37334245e61ab63c20ba623bb9a6242300dcf33f0b138bc852d177a12a8

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 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'] ||
          ENV['CI_COMMIT_SHA'] ||
          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-2.1.5 lib/codacy/git.rb
codacy-coverage-2.1.4 lib/codacy/git.rb
codacy-coverage-2.1.0 lib/codacy/git.rb