FIX repositories detail api bug

This commit is contained in:
jasder 2021-03-27 23:54:14 +08:00
parent e1d7b0b881
commit ad4617288d
2 changed files with 21 additions and 19 deletions

View File

@ -210,7 +210,7 @@ class RepositoriesController < ApplicationController
end end
def get_ref def get_ref
@ref = params[:ref] || @project.default_branch @ref = params[:ref] || @project&.default_branch
end end
def get_latest_commit def get_latest_commit

View File

@ -41,11 +41,13 @@ class Repositories::DetailService < ApplicationService
end end
def branch_suitable def branch_suitable
Gitea::Repository::Branches::ListService.call(@owner, @repo.identifier) branches = Gitea::Repository::Branches::ListService.call(@owner, @repo.identifier)
branches.is_a?(Hash) && branches[:status] == :error ? [] : branches
end end
def tag_suitable def tag_suitable
Gitea::Repository::Tags::ListService.call(@owner&.gitea_token, @owner.login, @repo.identifier) tags = Gitea::Repository::Tags::ListService.call(@owner&.gitea_token, @owner.login, @repo.identifier)
tags.is_a?(Hash) && tags[:status] == -1 ? [] : tags
end end
def contributor_suitable def contributor_suitable