You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/controllers/repositories_controller.rb

49 lines
1.6 KiB

6 years ago
class RepositoriesController < ApplicationController
5 years ago
include ApplicationHelper
before_action :find_user, :find_repository, :authorizate!
6 years ago
def show
@branches_count = Gitea::Repository::BranchesService.new(@user, @repo.identifier).call.size
@commits_count = Gitea::Repository::Commits::ListService.new(@user, @repo.identifier).call[:total_count]
end
5 years ago
def entries
@entries = Gitea::Repository::Entries::ListService.new(@user, @repo.identifier, ref: params[:ref]).call
5 years ago
@entries = @entries.sort_by{ |hash| hash['type'] }
5 years ago
end
def sub_entries
interactor = Repositories::EntriesInteractor.call(@user, @repo.identifier, params[:filepath], ref: params[:ref])
if interactor.success?
@sub_entries = interactor.result
5 years ago
if @sub_entries.is_a? Array
@entries = @entries.sort_by{ |hash| hash['type'] }
else
@sub_entries = [] << @sub_entries
end
# @sub_entries = [] << @sub_entries unless @sub_entries.is_a? Array
5 years ago
else
render_error(interactor.error)
end
end
def commits
@hash_commit = Gitea::Repository::Commits::ListService.new(@user, @repo.identifier, sha: params[:sha], page: params[:page]).call
end
def single_commit
@commit = Gitea::Repository::Commits::GetService.new(@user, @repo.identifier, params[:sha]).call
6 years ago
end
def tags
@tags = Gitea::Repository::Tags::ListService.new(@user, @repo.identifier).call
end
6 years ago
private
5 years ago
def authorizate!
if @repo.hidden? && @repo.user != current_user
render_forbidden
end
6 years ago
end
end