|
|
|
@@ -122,10 +122,10 @@ class RepositoriesController < ApplicationController |
|
|
|
if params[:filepath].present?
|
|
|
|
file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip))
|
|
|
|
@hash_commit = Gitea::Repository::Commits::FileListService.new(@owner.login, @project.identifier, file_path_uri,
|
|
|
|
sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call
|
|
|
|
sha: params[:sha], page: params[:page], limit: params[:limit], token: @owner&.gitea_token).call
|
|
|
|
else
|
|
|
|
@hash_commit = Gitea::Repository::Commits::ListService.new(@owner.login, @project.identifier,
|
|
|
|
sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call
|
|
|
|
sha: params[:sha], page: params[:page], limit: params[:limit], token: @owner&.gitea_token).call
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@@ -140,8 +140,8 @@ class RepositoriesController < ApplicationController |
|
|
|
if @project.educoder?
|
|
|
|
return render_error('暂未开放,敬请期待.')
|
|
|
|
else
|
|
|
|
@commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token)
|
|
|
|
@commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, current_user&.gitea_token, {diff: true})
|
|
|
|
@commit = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, @owner&.gitea_token)
|
|
|
|
@commit_diff = Gitea::Repository::Commits::GetService.call(@owner.login, @repository.identifier, @sha, @owner&.gitea_token, {diff: true})
|
|
|
|
render_error(@commit[:message], @commit[:status]) if @commit.has_key?(:status) || @commit_diff.has_key?(:status)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@@ -156,7 +156,7 @@ class RepositoriesController < ApplicationController |
|
|
|
|
|
|
|
@tag_names = result.is_a?(Hash) && result.key?(:status) ? [] : name_result
|
|
|
|
|
|
|
|
result = Gitea::Repository::Tags::ListService.call(current_user&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]})
|
|
|
|
result = Gitea::Repository::Tags::ListService.call(@owner&.gitea_token, @owner.login, @project.identifier, {page: params[:page], limit: params[:limit]})
|
|
|
|
|
|
|
|
@tags = result.is_a?(Hash) && result.key?(:status) ? [] : result
|
|
|
|
end
|
|
|
|
@@ -166,8 +166,9 @@ class RepositoriesController < ApplicationController |
|
|
|
if params[:filepath].present? || @project.educoder?
|
|
|
|
@contributors = []
|
|
|
|
else
|
|
|
|
result = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier)
|
|
|
|
@contributors = result.is_a?(Hash) && result.key?(:status) ? [] : result
|
|
|
|
result = Gitea::Repository::Contributors::GetService.call(@owner, @repository.identifier, {page: params[:page], limit: params[:limit]})
|
|
|
|
@total_count = result[:total_count]
|
|
|
|
@contributors = result.is_a?(Hash) ? result[:body] : []
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
@contributors = []
|
|
|
|
@@ -261,7 +262,7 @@ class RepositoriesController < ApplicationController |
|
|
|
archive_url = "/repos/#{@owner.login}/#{@repository.identifier}/archive/#{Addressable::URI.escape(params[:archive])}"
|
|
|
|
|
|
|
|
file_path = [domain, api_url, archive_url].join
|
|
|
|
file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("?") if @repository.hidden?
|
|
|
|
file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("?")
|
|
|
|
|
|
|
|
return render_not_found if !request.format.zip? && !request.format.gzip?
|
|
|
|
|
|
|
|
@@ -274,7 +275,7 @@ class RepositoriesController < ApplicationController |
|
|
|
|
|
|
|
url = "/repos/#{@owner.login}/#{@repository.identifier}/raw/#{Addressable::URI.escape(params[:filepath])}?ref=#{Addressable::URI.escape(params[:ref])}"
|
|
|
|
file_path = [domain, api_url, url].join
|
|
|
|
file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("&")
|
|
|
|
file_path = [file_path, "access_token=#{@owner&.gitea_token}"].join("&")
|
|
|
|
|
|
|
|
redirect_to file_path
|
|
|
|
end
|
|
|
|
@@ -302,16 +303,16 @@ class RepositoriesController < ApplicationController |
|
|
|
if params[:filepath].present?
|
|
|
|
file_path_uri = URI.parse(URI.encode(params[:filepath].to_s.strip))
|
|
|
|
Gitea::Repository::Commits::FileListService.new(@project.owner.login, @project.identifier, file_path_uri,
|
|
|
|
sha: get_ref, page: 1, limit: 1, token: current_user&.gitea_token).call
|
|
|
|
sha: get_ref, page: 1, limit: 1, token: @project&.owner&.gitea_token).call
|
|
|
|
else
|
|
|
|
Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier,
|
|
|
|
sha: get_ref, page: 1, limit: 1, token: current_user&.gitea_token).call
|
|
|
|
sha: get_ref, page: 1, limit: 1, token: @project&.owner&.gitea_token).call
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_statistics
|
|
|
|
@branches_count = @project.educoder? ? 0 : Gitea::Repository::Branches::ListService.new(@project.owner, @project.identifier).call&.size
|
|
|
|
@tags_count = @project.educoder? ? 0 : Gitea::Repository::Tags::ListService.new(current_user&.gitea_token, @project.owner.login, @project.identifier).call&.size
|
|
|
|
@tags_count = @project.educoder? ? 0 : Gitea::Repository::Tags::ListService.new(@project&.owner&.gitea_token, @project.owner.login, @project.identifier).call&.size
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_ref
|
|
|
|
|