FIX repositories controller bug
This commit is contained in:
parent
066dede6e3
commit
082c3b05b3
|
@ -10,7 +10,7 @@ module OperateProjectAbilityAble
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorizate_user_can_edit_repo!
|
def authorizate_user_can_edit_repo!
|
||||||
return if @repo.project.manager?(current_user) || current_user.admin?
|
return if @repository.project.manager?(current_user) || current_user.admin?
|
||||||
render_forbidden('你没有权限操作.')
|
render_forbidden('你没有权限操作.')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@ class RepositoriesController < ApplicationController
|
||||||
include OperateProjectAbilityAble
|
include OperateProjectAbilityAble
|
||||||
|
|
||||||
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
||||||
before_action :load_project
|
before_action :load_repository
|
||||||
before_action :authorizate!, except: [:sync_mirror, :tags, :commit]
|
before_action :authorizate!, except: [:sync_mirror, :tags, :commit]
|
||||||
before_action :find_repository_by_id, only: %i[commit sync_mirror]
|
|
||||||
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
||||||
before_action :get_ref, only: %i[entries sub_entries top_counts]
|
before_action :get_ref, only: %i[entries sub_entries top_counts]
|
||||||
before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
|
before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
|
||||||
|
@ -56,7 +55,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def commit
|
def commit
|
||||||
@commit = Gitea::Repository::Commits::GetService.new(@repo.user.login, @repo.identifier, params[:sha], current_user.gitea_token).call
|
@commit = Gitea::Repository::Commits::GetService.new(@repository.user.login, @repository.identifier, params[:sha], current_user.gitea_token).call
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
|
@ -102,10 +101,10 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync_mirror
|
def sync_mirror
|
||||||
return render_error("正在镜像中..") if @repo.mirror.waiting?
|
return render_error("正在镜像中..") if @repository.mirror.waiting?
|
||||||
|
|
||||||
@repo.sync_mirror!
|
@repository.sync_mirror!
|
||||||
SyncMirroredRepositoryJob.perform_later(@repo.id, current_user.id)
|
SyncMirroredRepositoryJob.perform_later(@repository.id, current_user.id)
|
||||||
render_ok
|
render_ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -155,23 +155,6 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :repositories, only: [:index, :show, :edit] do
|
|
||||||
member do
|
|
||||||
get :entries
|
|
||||||
match :sub_entries, :via => [:get, :put]
|
|
||||||
get :commits
|
|
||||||
post :files
|
|
||||||
get :tags
|
|
||||||
post :create_file
|
|
||||||
put :update_file
|
|
||||||
delete :delete_file
|
|
||||||
post :repo_hook
|
|
||||||
post :sync_mirror
|
|
||||||
get :top_counts
|
|
||||||
get 'commits/:sha', to: 'repositories#commit', as: 'commit'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
resources :users_for_private_messages, only: [:index]
|
resources :users_for_private_messages, only: [:index]
|
||||||
|
|
||||||
resources :files, only: [:index, :show, :update] do
|
resources :files, only: [:index, :show, :update] do
|
||||||
|
@ -286,12 +269,19 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resource :repositories, path: '/', only: [:show, :create, :edit] do
|
resource :repositories, path: '/', only: [:show, :create, :edit] do
|
||||||
member do
|
member do
|
||||||
get 'archive'
|
get :archive
|
||||||
get 'top_counts'
|
get :top_counts
|
||||||
get 'entries'
|
get :entries
|
||||||
get 'sub_entries'
|
match :sub_entries, :via => [:get, :put]
|
||||||
get 'commits'
|
get :commits
|
||||||
get 'tags'
|
get :tags
|
||||||
|
post :create_file
|
||||||
|
put :update_file
|
||||||
|
delete :delete_file
|
||||||
|
post :repo_hook
|
||||||
|
post :sync_mirror
|
||||||
|
get :top_counts
|
||||||
|
get 'commits/:sha', to: 'repositories#commit', as: 'commit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue