Sha256: 572a544db952881aac9e34a7d06fd020d9657e6206f24ef552413876d2601229

Contents?: true

Size: 1.9 KB

Versions: 19

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

require_relative "base"
require_relative "../../../git/local_repository"

module Datadog
  module CI
    module Ext
      module Environment
        module Providers
          # As a fallback we try to fetch git information from the local git repository
          class LocalGit < Base
            def git_repository_url
              CI::Git::LocalRepository.git_repository_url
            end

            def git_commit_sha
              CI::Git::LocalRepository.git_commit_sha
            end

            def git_branch
              CI::Git::LocalRepository.git_branch
            end

            def git_tag
              CI::Git::LocalRepository.git_tag
            end

            def git_commit_message
              CI::Git::LocalRepository.git_commit_message
            end

            def git_commit_author_name
              author.name
            end

            def git_commit_author_email
              author.email
            end

            def git_commit_author_date
              author.date
            end

            def git_commit_committer_name
              committer.name
            end

            def git_commit_committer_email
              committer.email
            end

            def git_commit_committer_date
              committer.date
            end

            def workspace_path
              CI::Git::LocalRepository.git_root
            end

            private

            def author
              return @author if defined?(@author)

              set_git_commit_users
              @author
            end

            def committer
              return @committer if defined?(@committer)

              set_git_commit_users
              @committer
            end

            def set_git_commit_users
              @author, @committer = CI::Git::LocalRepository.git_commit_users
            end
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
datadog-ci-1.12.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.11.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.10.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.9.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.8.1 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.8.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.7.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.6.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.5.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.4.1 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.4.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.3.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.2.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.1.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.0.1 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.0.0 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.0.0.beta6 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.0.0.beta3 lib/datadog/ci/ext/environment/providers/local_git.rb
datadog-ci-1.0.0.beta2 lib/datadog/ci/ext/environment/providers/local_git.rb