Sha256: f27f5a3bc2a48bafe1a4c5d521b35b4711b60f867e47d6bc8b0ecf3da08ff73e

Contents?: true

Size: 1.67 KB

Versions: 9

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

module Shipit
  class RepositoriesController < ShipitController
    before_action :load_repository, only: %i(destroy settings update new_stack)

    def index
      @user_repositories = current_user.repositories_contributed_to

      @repositories = Repository.order(:owner, :name).to_a
    end

    def show
      @repository = Repository.from_param!(params[:id])

      @stacks = @repository.stacks

      @show_archived = params[:show_archived]
      @stacks = @stacks.not_archived unless @show_archived
    end

    def create
      @repository = Repository.new(create_params)
      unless @repository.save
        flash[:warning] = @repository.errors.full_messages.to_sentence
      end
      respond_with(@repository)
    end

    def new
      @repository = Repository.new
    end

    def destroy
      @repository.schedule_for_destroy!
      redirect_to(repositories_url)
    end

    def update
      options = {}
      unless @repository.update(update_params)
        options = { flash: { warning: @repository.errors.full_messages.to_sentence } }
      end

      redirect_to(params[:return_to].presence || repository_settings_path(@repository), options)
    end

    def settings
    end

    def new_stack
      @stack = @repository.stacks.new
      render("shipit/stacks/new")
    end

    private

    def create_params
      params.require(:repository).permit(:owner, :name)
    end

    def update_params
      params.require(:repository).permit(
        :review_stacks_enabled,
        :provisioning_behavior,
        :provisioning_label_name,
      )
    end

    def load_repository
      @repository = Repository.from_param!(params[:id])
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.38.0 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.37.0 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.36.1 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.36.0 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.35.1 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.35.0 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.34.0 app/controllers/shipit/repositories_controller.rb
shipit-engine-0.33.0 app/controllers/shipit/repositories_controller.rb