diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index d5e259893..f03215ace 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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