Sha256: 02073ef004306604099e11d72c48f4b43bc0053d0bd8d335a4cf6d29a474707d

Contents?: true

Size: 1.6 KB

Versions: 3

Compression:

Stored size: 1.6 KB

Contents

require 'travis/cli'

module Travis
  module CLI
    class Requests < RepoCommand
      description "lists recent requests"

      def run
        repository.requests.each do |request|
          style ||= :success if request.accepted?
          style ||= :error   if request.rejected?
          style ||= :info

          case request.event_type
          when 'push'
            result      = request.result || "received"
            message     = request.message
            message   ||= "validation pending"  unless request.rejected? or request.accepted?
            message   ||= "unknown reason"      unless request.accepted?
            message   ||= "triggered new build" unless request.rejected?
            description = "push to #{request.branch || request.tag || "???"}"
          when 'pull_request'
            result      = request.result || "received"
            message     = request.message
            message   ||= "HEAD commit not updated" unless request.accepted?
            message   ||= "triggered new build"     unless request.rejected?
            description = "push to #{request.branch || request.tag || "???"}"
            description = "PR ##{request.pull_request_number}"
          end

          say [
            color(description, [:bold, style]),
            color(result, style),
            color("(#{message})", style)
          ].join(" ").strip + "\n"

          say "  " + color(request.commit.short_sha, :bold) + " - " + request.commit.subject if request.commit
          say "  received at: #{formatter.time(request.created_at)}"
          empty_line
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
travis-1.6.9.travis.458.6 lib/travis/cli/requests.rb
travis-1.6.8 lib/travis/cli/requests.rb
travis-1.6.8.travis.457.6 lib/travis/cli/requests.rb