Sha256: fa5b6e4b75a93dc05b0204c2a9f8b4ce557f51a240309f1c4e8cc098880b57e4

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require "forwardable"

module Git
  module Lint
    module Branches
      # Represents a feature branch.
      class Feature
        extend Forwardable

        def_delegators :selected_environment, :name, :shas

        def initialize environment: ENV, git_repo: Git::Kit::Repo.new
          message = "Invalid repository. Are you within a Git-enabled project?"
          fail Errors::Base, message unless git_repo.exist?

          @current_environment = environment
          @selected_environment = load_environment
        end

        def commits
          shas.map { |sha| Commits::Saved.new sha: sha }
        end

        private

        attr_reader :current_environment, :selected_environment

        def load_environment
          if key? "CIRCLECI" then Environments::CircleCI.new
          elsif key? "NETLIFY" then Environments::NetlifyCI.new environment: current_environment
          elsif key? "TRAVIS" then Environments::TravisCI.new environment: current_environment
          else Environments::Local.new
          end
        end

        def key? key
          current_environment[key] == "true"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-lint-1.1.1 lib/git/lint/branches/feature.rb
git-lint-1.1.0 lib/git/lint/branches/feature.rb
git-lint-1.0.1 lib/git/lint/branches/feature.rb
git-lint-1.0.0 lib/git/lint/branches/feature.rb