Sha256: 30d18265c681d49dc6ef494154c90a14a426e20800a469c90b50574503868d85

Contents?: true

Size: 1.03 KB

Versions: 15

Compression:

Stored size: 1.03 KB

Contents

module Shipit
  module Api
    class PullRequestsController < BaseController
      require_permission :read, :stack
      require_permission :deploy, :stack, only: %i(update destroy)

      def index
        render_resources stack.pull_requests.includes(:head).order(id: :desc)
      end

      def show
        render_resource stack.pull_requests.find_by!(number: params[:id])
      end

      def update
        pull_request = PullRequest.request_merge!(stack, params[:id], current_user)
        if pull_request.waiting?
          head :accepted
        elsif pull_request.merged?
          render status: :method_not_allowed, json: {
            message: "This pull request was already merged.",
          }
        else
          raise "Pull Request is neither waiting nor merged, this should be impossible"
        end
      end

      def destroy
        if pull_request = stack.pull_requests.where(number: params[:id]).first
          pull_request.cancel! if pull_request.waiting?
        end
        head :no_content
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.30.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.29.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.28.1 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.28.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.27.1 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.27.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.26.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.25.1 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.25.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.24.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.23.1 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.23.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.22.0 app/controllers/shipit/api/pull_requests_controller.rb
shipit-engine-0.21.0 app/controllers/shipit/api/pull_requests_controller.rb