FIX sync mirror api bug

This commit is contained in:
Jasder 2020-06-02 15:00:05 +08:00
parent ffa4a948ee
commit 15e90e95cc
2 changed files with 5 additions and 10 deletions

View File

@ -2,11 +2,10 @@ class RepositoriesController < ApplicationController
include ApplicationHelper
include OperateProjectAbilityAble
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
before_action :find_project, except: [:tags, :commit]
before_action :find_project, except: [:tags, :commit, :sync_mirror]
before_action :authorizate!, except: [:sync_mirror, :tags, :commit]
before_action :find_repository, only: %i[sync_mirror tags]
before_action :authorizate_user_can_edit_project!, only: %i[sync_mirror]
before_action :find_repository_by_id, only: %i[commit]
before_action :find_repository_by_id, only: %i[commit sync_mirror tags]
def show
@branches_count = Gitea::Repository::BranchesService.new(@project.owner, @project.identifier).call&.size
@ -45,7 +44,8 @@ class RepositoriesController < ApplicationController
end
def commits
@hash_commit = Gitea::Repository::Commits::ListService.new(@project.owner.login, @project.identifier,
@project_owner = @project.owner
@hash_commit = Gitea::Repository::Commits::ListService.new(@project_owner.login, @project.identifier,
sha: params[:sha], page: params[:page], limit: params[:limit], token: current_user&.gitea_token).call
end
@ -123,10 +123,6 @@ class RepositoriesController < ApplicationController
render_not_found("未找到相关的仓库") unless @project
end
def find_repository
@repo = Repository.find params[:id]
end
def authorizate!
if @project.repository.hidden? && !@project.member?(current_user)
render_forbidden

View File

@ -9,8 +9,7 @@ else
json.message commit['commit']['message']
json.timestamp render_unix_time(commit['commit']['author']['date'])
json.time_from_now time_from_now(commit['commit']['author']['date'])
json.partial! 'author', user: @project.owner
json.partial! 'author', user: @project_owner.owner
end
end
end