Sha256: 202bf0d2bc5c080ca74ca203cdb479af45e103e4893e1c8dd4a6c4d959e27cf0

Contents?: true

Size: 891 Bytes

Versions: 10

Compression:

Stored size: 891 Bytes

Contents

module Shipit
  class MergePullRequestsJob < BackgroundJob
    include BackgroundJob::Unique
    on_duplicate :drop

    queue_as :default

    def perform(stack)
      pull_requests = stack.pull_requests.to_be_merged.to_a
      pull_requests.each do |pull_request|
        pull_request.refresh!
        pull_request.reject_unless_mergeable!
        pull_request.cancel! if pull_request.closed?
        pull_request.revalidate! if pull_request.need_revalidation?
      end

      return false unless stack.allows_merges?

      pull_requests.select(&:pending?).each do |pull_request|
        pull_request.refresh!
        next unless pull_request.all_status_checks_passed?
        begin
          pull_request.merge!
        rescue PullRequest::NotReady
          MergePullRequestsJob.set(wait: 10.seconds).perform_later(stack)
          return false
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.30.0 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.29.0 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.28.1 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.28.0 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.27.1 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.27.0 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.26.0 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.25.1 app/jobs/shipit/merge_pull_requests_job.rb
shipit-engine-0.25.0 app/jobs/shipit/merge_pull_requests_job.rb