Sha256: 622d2dd090622f1b50808335fcaf85d6904df80b4e8a8f5b39541216262e517f

Contents?: true

Size: 1.75 KB

Versions: 284

Compression:

Stored size: 1.75 KB

Contents

require 'travis/cli'

module Travis
  module CLI
    class Requests < RepoCommand
      description "lists recent requests"
      on '-l', '--limit LIMIT', 'Maximum number requests to display'

      def run
        requests = repository.requests
        requests = requests[0, Integer(limit)] if limit
        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

284 entries across 284 versions & 3 rubygems

Version Path
travis-1.11.1 lib/travis/cli/requests.rb
travis-1.11.0 lib/travis/cli/requests.rb
travis-1.10.1.travis.1341.9 lib/travis/cli/requests.rb
travis-1.10.1.travis.1321.9 lib/travis/cli/requests.rb
travis-1.10.1.travis.1312.9 lib/travis/cli/requests.rb
travis-1.10.1.travis.1311.9 lib/travis/cli/requests.rb
travis-1.10.1.travis.1305.9 lib/travis/cli/requests.rb
travis-1.10.0 lib/travis/cli/requests.rb
travis-1.9.2.travis.1304.9 lib/travis/cli/requests.rb
travis-1.9.2.travis.1303.9 lib/travis/cli/requests.rb
travis-1.10.0.pre.rc4 lib/travis/cli/requests.rb
travis-1.10.0.pre.rc3 lib/travis/cli/requests.rb
travis-1.10.0.pre.rc2 lib/travis/cli/requests.rb
travis-1.9.2.travis.1288.9 lib/travis/cli/requests.rb
travis-1.9.2.travis.1285.9 lib/travis/cli/requests.rb
travis-1.9.2.travis.1279.9 lib/travis/cli/requests.rb
travis-1.10.0.pre.rc1 lib/travis/cli/requests.rb
travis-1.9.2.travis.1254.9 lib/travis/cli/requests.rb
travis-1.9.2.travis.1236.9 lib/travis/cli/requests.rb
travis-1.9.2.travis.1224.9 lib/travis/cli/requests.rb