Sha256: f256112c9fd8a9e8570476271521bb6ceb47845d2fee39c7d7f2b6d1cf312002

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

module Jets::Git
  class Info
    extend Memoist
    # Not using options but trying to future proof initialize
    def initialize(options={})
      @options = options
    end

    def user
      User.new
    end
    memoize :user

    # Best effort to get git info
    def params
      return {} if ENV['JETS_GIT_DISABLED']
      strategy_class.new.params
    end

    def strategy_class
      env_map = {
        BITBUCKET_COMMIT: Bitbucket,
        CIRCLECI: Circleci,
        CODEBUILD_CI: Codebuild,
        GITHUB_ACTIONS: Github,
        GITLAB_CI: Gitlab,
        JETS_GIT_CUSTOM: Custom,
        SYSTEM_TEAMFOUNDATIONSERVERURI: Azure,
      }
      found = env_map.find do |env_key, strategy_class|
        ENV[env_key.to_s]
      end
      found ? found[1] : Local
    end
    memoize :strategy_class
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jets-git-0.2.1 lib/jets/git/info.rb
jets-git-0.2.0 lib/jets/git/info.rb