Sha256: 83cbed9aa29ff52a8637845892ff8690ed86855e9fc32c228e2a88e235bcdc5d

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

module Janky
  class BuildRequest
    def self.handle(repo_uri, branch_name, pusher, commit, compare, room_id)
      repos = Repository.find_all_by_uri(repo_uri)
      repos.each do |repo|
        begin
          new(repo, branch_name, pusher, commit, compare, room_id).handle
        rescue Janky::Error => boom
          Exception.report(boom, :repo => repo.name)
        end
      end

      repos.size
    end

    def initialize(repo, branch_name, pusher, commit, compare, room_id)
      @repo        = repo
      @branch_name = branch_name
      @pusher      = pusher
      @commit      = commit
      @compare     = compare
      @room_id     = room_id
    end

    def handle
      current_build = commit.last_build
      build = branch.build_for(commit, @pusher, @room_id, @compare)

      if !current_build || (current_build && current_build.red?)
        if @repo.enabled?
          build.run
        end
      end
    end

    def branch
      @repo.branch_for(@branch_name)
    end

    def commit
      @repo.commit_for(
        :sha1         => @commit.sha1,
        :url          => @commit.url,
        :message      => @commit.message,
        :author       => @commit.author,
        :committed_at => @commit.committed_at
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
janky-0.10.2 lib/janky/build_request.rb
janky-0.10.0 lib/janky/build_request.rb
janky-0.9.15 lib/janky/build_request.rb
janky-0.9.14 lib/janky/build_request.rb
janky-0.9.14.rc1 lib/janky/build_request.rb
janky-0.9.13 lib/janky/build_request.rb