forked from Gitlink/forgeplus
修改commits报错
This commit is contained in:
commit
d1089a4a4b
|
@ -9,4 +9,9 @@ module OperateProjectAbilityAble
|
|||
render_forbidden('你没有权限操作.')
|
||||
end
|
||||
|
||||
def authorizate_user_can_edit_repo!
|
||||
return if @repo.project.manager?(current_user) || current_user.admin?
|
||||
render_forbidden('你没有权限操作.')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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]
|
||||
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
||||
|
||||
def show
|
||||
@branches_count = Gitea::Repository::BranchesService.new(@project.owner, @project.identifier).call&.size
|
||||
|
@ -45,8 +44,8 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def commits
|
||||
@create_user = @project.owner
|
||||
@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
|
||||
|
||||
|
@ -113,7 +112,7 @@ class RepositoriesController < ApplicationController
|
|||
|
||||
def sync_mirror
|
||||
@repo&.mirror.set_status!(Mirror.statuses[:waiting])
|
||||
SyncMirroredRepositoryJob(@repo, current_user)
|
||||
SyncMirroredRepositoryJob.perform_later(@repo, current_user)
|
||||
render_ok
|
||||
end
|
||||
|
||||
|
@ -124,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
|
||||
|
|
|
@ -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', locals: {user: @create_user}
|
||||
json.partial! 'author', user: @project_owner
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue