class Git::Lint::Branches::Environments::TravisCI

Provides Travis CI build environment feature branch information.

Public Class Methods

new(repository: GitPlus::Repository.new, shell: Open3, environment: ENV) click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 11
def initialize repository: GitPlus::Repository.new, shell: Open3, environment: ENV
  @repository = repository
  @shell = shell
  @environment = environment
end

Public Instance Methods

ci_branch(= environment["TRAVIS_BRANCH"]) click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 40
      def ci_branch = environment["TRAVIS_BRANCH"]

      def pull_request_branch = environment["TRAVIS_PULL_REQUEST_BRANCH"]

      def pull_request_slug = environment["TRAVIS_PULL_REQUEST_SLUG"]
    end
  end
end
commits() click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 19
def commits
  prepare_project
  repository.commits "origin/#{repository.branch_default}..#{name}"
end
name(= pull_request_branch.empty? ? ci_branch : pull_request_branch) click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 17
        def name = pull_request_branch.empty? ? ci_branch : pull_request_branch

        def commits
          prepare_project
          repository.commits "origin/#{repository.branch_default}..#{name}"
        end

        private

        attr_reader :environment, :repository, :shell

        def prepare_project
          slug = pull_request_slug

          unless slug.empty?
            shell.capture3 "git remote add -f original_branch https://github.com/#{slug}.git"
            shell.capture3 "git fetch original_branch #{name}:#{name}"
          end

          shell.capture3 "git remote set-branches --add origin #{repository.branch_default}"
          shell.capture3 "git fetch"
        end

        def ci_branch = environment["TRAVIS_BRANCH"]

        def pull_request_branch = environment["TRAVIS_PULL_REQUEST_BRANCH"]

        def pull_request_slug = environment["TRAVIS_PULL_REQUEST_SLUG"]
      end
    end
  end
end
prepare_project() click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 28
def prepare_project
  slug = pull_request_slug

  unless slug.empty?
    shell.capture3 "git remote add -f original_branch https://github.com/#{slug}.git"
    shell.capture3 "git fetch original_branch #{name}:#{name}"
  end

  shell.capture3 "git remote set-branches --add origin #{repository.branch_default}"
  shell.capture3 "git fetch"
end
pull_request_branch(= environment["TRAVIS_PULL_REQUEST_BRANCH"]) click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 42
    def pull_request_branch = environment["TRAVIS_PULL_REQUEST_BRANCH"]

    def pull_request_slug = environment["TRAVIS_PULL_REQUEST_SLUG"]
  end
end
pull_request_slug(= environment["TRAVIS_PULL_REQUEST_SLUG"]) click to toggle source
# File lib/git/lint/branches/environments/travis_ci.rb, line 44
  def pull_request_slug = environment["TRAVIS_PULL_REQUEST_SLUG"]
end