Merge branch 'dev_change_route' into dev_devops
This commit is contained in:
commit
7a2d7f50fd
|
@ -38,12 +38,12 @@ class IssueTagsController < ApplicationController
|
||||||
begin
|
begin
|
||||||
issue_tag = IssueTag.new(tag_params.merge(project_id: @project.id, user_id: current_user.id))
|
issue_tag = IssueTag.new(tag_params.merge(project_id: @project.id, user_id: current_user.id))
|
||||||
if issue_tag.save
|
if issue_tag.save
|
||||||
gitea_tag = Gitea::Labels::CreateService.new(current_user, @repository.try(:identifier), tag_params).call
|
# gitea_tag = Gitea::Labels::CreateService.new(current_user, @repository.try(:identifier), tag_params).call
|
||||||
if gitea_tag && issue_tag.update_attributes(gid: gitea_tag["id"], gitea_url: gitea_tag["url"])
|
# if gitea_tag && issue_tag.update_attributes(gid: gitea_tag["id"], gitea_url: gitea_tag["url"])
|
||||||
normal_status(0, "标签创建成功")
|
# normal_status(0, "标签创建成功")
|
||||||
else
|
# else
|
||||||
normal_status(-1, "标签创建失败")
|
# normal_status(-1, "标签创建失败")
|
||||||
end
|
# end
|
||||||
else
|
else
|
||||||
normal_status(-1, "标签创建失败")
|
normal_status(-1, "标签创建失败")
|
||||||
end
|
end
|
||||||
|
@ -79,12 +79,12 @@ class IssueTagsController < ApplicationController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
begin
|
begin
|
||||||
if @issue_tag.update_attributes(tag_params)
|
if @issue_tag.update_attributes(tag_params)
|
||||||
gitea_tag = Gitea::Labels::UpdateService.new(current_user, @repository.try(:identifier),@issue_tag.try(:gid), tag_params).call
|
# gitea_tag = Gitea::Labels::UpdateService.new(current_user, @repository.try(:identifier),@issue_tag.try(:gid), tag_params).call
|
||||||
if gitea_tag
|
# if gitea_tag
|
||||||
normal_status(0, "标签更新成功")
|
# normal_status(0, "标签更新成功")
|
||||||
else
|
# else
|
||||||
normal_status(-1, "标签更新失败")
|
# normal_status(-1, "标签更新失败")
|
||||||
end
|
# end
|
||||||
else
|
else
|
||||||
normal_status(-1, "标签更新失败")
|
normal_status(-1, "标签更新失败")
|
||||||
end
|
end
|
||||||
|
@ -103,12 +103,12 @@ class IssueTagsController < ApplicationController
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
begin
|
begin
|
||||||
if @issue_tag.destroy
|
if @issue_tag.destroy
|
||||||
issue_tag = Gitea::Labels::DeleteService.new(@user, @repository.try(:identifier), @issue_tag.try(:gid)).call
|
# issue_tag = Gitea::Labels::DeleteService.new(@user, @repository.try(:identifier), @issue_tag.try(:gid)).call
|
||||||
if issue_tag
|
# if issue_tag
|
||||||
normal_status(0, "标签删除成功")
|
# normal_status(0, "标签删除成功")
|
||||||
else
|
# else
|
||||||
normal_status(-1, "标签删除失败")
|
# normal_status(-1, "标签删除失败")
|
||||||
end
|
# end
|
||||||
else
|
else
|
||||||
normal_status(-1, "标签删除失败")
|
normal_status(-1, "标签删除失败")
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,8 +2,8 @@ class ProjectsController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include OperateProjectAbilityAble
|
include OperateProjectAbilityAble
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
before_action :require_login, except: %i[index branches group_type_list simple show]
|
before_action :require_login, except: %i[index branches group_type_list simple show fork_users praise_users watch_users]
|
||||||
before_action :load_project, except: %i[index group_type_list migrate]
|
before_action :load_project, except: %i[index group_type_list migrate create]
|
||||||
before_action :authorizate_user_can_edit_project!, only: %i[update]
|
before_action :authorizate_user_can_edit_project!, only: %i[update]
|
||||||
before_action :project_public?, only: %i[fork_users praise_users watch_users]
|
before_action :project_public?, only: %i[fork_users praise_users watch_users]
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_file
|
def create_file
|
||||||
interactor = Gitea::CreateFileInteractor.call(current_user, content_params)
|
interactor = Gitea::CreateFileInteractor.call(current_user.gitea_token, @project.owner.login, content_params)
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
@file = interactor.result
|
@file = interactor.result
|
||||||
create_new_pr(params)
|
create_new_pr(params)
|
||||||
|
@ -76,7 +76,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_file
|
def update_file
|
||||||
interactor = Gitea::UpdateFileInteractor.call(current_user, params.merge(identifier: @project.identifier))
|
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @project.owner.login, params.merge(identifier: @project.identifier))
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
@file = interactor.result
|
@file = interactor.result
|
||||||
create_new_pr(params)
|
create_new_pr(params)
|
||||||
|
@ -87,7 +87,7 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_file
|
def delete_file
|
||||||
interactor = Gitea::DeleteFileInteractor.call(current_user, params.merge(identifier: @project.identifier))
|
interactor = Gitea::DeleteFileInteractor.call(current_user.gitea_token, @project.owner.login, params.merge(identifier: @project.identifier))
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
@file = interactor.result
|
@file = interactor.result
|
||||||
render_result(1, "文件删除成功")
|
render_result(1, "文件删除成功")
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
module Gitea
|
module Gitea
|
||||||
class CreateFileInteractor
|
class CreateFileInteractor
|
||||||
def self.call(user, params={})
|
def self.call(token, owner, params={})
|
||||||
interactor = new(user, params)
|
interactor = new(token, owner, params)
|
||||||
interactor.run
|
interactor.run
|
||||||
interactor
|
interactor
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :error, :result
|
attr_reader :error, :result
|
||||||
|
|
||||||
def initialize(user, params)
|
def initialize(token, owner, params)
|
||||||
@user = user
|
@owner = owner
|
||||||
@params = params
|
@params = params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ module Gitea
|
||||||
|
|
||||||
def run
|
def run
|
||||||
Contents::CreateForm.new(valid_params).validate!
|
Contents::CreateForm.new(valid_params).validate!
|
||||||
response = Gitea::Repository::Entries::CreateService.new(user, @params[:identifier], @params[:filepath], file_params).call
|
response = Gitea::Repository::Entries::CreateService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call
|
||||||
render_result(response)
|
render_result(response)
|
||||||
rescue Exception => exception
|
rescue Exception => exception
|
||||||
Rails.logger.info "Exception ===========> #{exception.message}"
|
Rails.logger.info "Exception ===========> #{exception.message}"
|
||||||
|
@ -33,7 +33,7 @@ module Gitea
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :params, :user
|
attr_reader :params, :owner, :token
|
||||||
|
|
||||||
def fail!(error)
|
def fail!(error)
|
||||||
@error = error
|
@error = error
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
module Gitea
|
module Gitea
|
||||||
class DeleteFileInteractor
|
class DeleteFileInteractor
|
||||||
def self.call(user, params={})
|
def self.call(token, owner, params={})
|
||||||
interactor = new(user, params)
|
interactor = new(token, owner, params)
|
||||||
interactor.run
|
interactor.run
|
||||||
interactor
|
interactor
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :error, :result
|
attr_reader :error, :result
|
||||||
|
|
||||||
def initialize(user, params)
|
def initialize(token, owner, params)
|
||||||
@user = user
|
@token = token
|
||||||
|
@owner = owner
|
||||||
@params = params
|
@params = params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ module Gitea
|
||||||
|
|
||||||
def run
|
def run
|
||||||
Contents::DeleteForm.new(valid_params).validate!
|
Contents::DeleteForm.new(valid_params).validate!
|
||||||
response = Gitea::Repository::Entries::DeleteService.new(user, @params[:identifier], @params[:filepath], file_params).call
|
response = Gitea::Repository::Entries::DeleteService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call
|
||||||
render_result(response)
|
render_result(response)
|
||||||
rescue Exception => exception
|
rescue Exception => exception
|
||||||
fail!(exception.message)
|
fail!(exception.message)
|
||||||
|
@ -31,7 +32,7 @@ module Gitea
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :params, :user
|
attr_reader :params, :owner, :token
|
||||||
|
|
||||||
def fail!(error)
|
def fail!(error)
|
||||||
puts "[exception]: error"
|
puts "[exception]: error"
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
module Gitea
|
module Gitea
|
||||||
class UpdateFileInteractor
|
class UpdateFileInteractor
|
||||||
def self.call(user, params={})
|
def self.call(token, owner, params={})
|
||||||
interactor = new(user, params)
|
interactor = new(token, owner, params)
|
||||||
interactor.run
|
interactor.run
|
||||||
interactor
|
interactor
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :error, :result
|
attr_reader :error, :result
|
||||||
|
|
||||||
def initialize(user, params)
|
def initialize(token, owner, params)
|
||||||
@user = user
|
@owner = owner
|
||||||
|
@token = token
|
||||||
@params = params
|
@params = params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ module Gitea
|
||||||
|
|
||||||
def run
|
def run
|
||||||
Contents::UpdateForm.new(valid_params).validate!
|
Contents::UpdateForm.new(valid_params).validate!
|
||||||
response = Gitea::Repository::Entries::UpdateService.new(user, @params[:identifier], @params[:filepath], file_params).call
|
response = Gitea::Repository::Entries::UpdateService.new(token, owner, @params[:identifier], @params[:filepath], file_params).call
|
||||||
render_result(response)
|
render_result(response)
|
||||||
rescue Exception => exception
|
rescue Exception => exception
|
||||||
fail!(exception.message)
|
fail!(exception.message)
|
||||||
|
@ -31,7 +32,7 @@ module Gitea
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :params, :user
|
attr_reader :params, :owner, :token
|
||||||
|
|
||||||
def fail!(error)
|
def fail!(error)
|
||||||
puts "[exception]: error"
|
puts "[exception]: error"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
||||||
attr_reader :user, :repo_name, :filepath, :body
|
attr_reader :token, :owner, :repo_name, :filepath, :body
|
||||||
|
|
||||||
# ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master)
|
# ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master)
|
||||||
# filepath: path of the dir, file, symlink or submodule in the repo
|
# filepath: path of the dir, file, symlink or submodule in the repo
|
||||||
|
@ -20,8 +20,9 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
||||||
# "new_branch": "string"
|
# "new_branch": "string"
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
def initialize(user, repo_name, filepath, body)
|
def initialize(token, owner, repo_name, filepath, body)
|
||||||
@user = user
|
@token = token
|
||||||
|
@owner = owner
|
||||||
@repo_name = repo_name
|
@repo_name = repo_name
|
||||||
@filepath = filepath
|
@filepath = filepath
|
||||||
@body = body
|
@body = body
|
||||||
|
@ -33,11 +34,11 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService
|
||||||
|
|
||||||
private
|
private
|
||||||
def params
|
def params
|
||||||
Hash.new.merge(token: user.gitea_token, data: body)
|
Hash.new.merge(token: token, data: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/repos/#{user.login}/#{repo_name}/contents/#{filepath}".freeze
|
"/repos/#{owner}/#{repo_name}/contents/#{filepath}".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Gitea::Repository::Entries::DeleteService < Gitea::ClientService
|
class Gitea::Repository::Entries::DeleteService < Gitea::ClientService
|
||||||
attr_reader :user, :repo_name, :filepath, :body
|
attr_reader :token, :owner, :repo_name, :filepath, :body
|
||||||
|
|
||||||
# ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master)
|
# ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master)
|
||||||
# filepath: path of the dir, file, symlink or submodule in the repo
|
# filepath: path of the dir, file, symlink or submodule in the repo
|
||||||
|
@ -19,8 +19,9 @@ class Gitea::Repository::Entries::DeleteService < Gitea::ClientService
|
||||||
# "new_branch": "string",
|
# "new_branch": "string",
|
||||||
# "sha": "string", #require
|
# "sha": "string", #require
|
||||||
# }
|
# }
|
||||||
def initialize(user, repo_name, filepath, body)
|
def initialize(token, owner, repo_name, filepath, body)
|
||||||
@user = user
|
@token = token
|
||||||
|
@owner = owner
|
||||||
@repo_name = repo_name
|
@repo_name = repo_name
|
||||||
@filepath = filepath
|
@filepath = filepath
|
||||||
@body = body
|
@body = body
|
||||||
|
@ -32,11 +33,11 @@ class Gitea::Repository::Entries::DeleteService < Gitea::ClientService
|
||||||
|
|
||||||
private
|
private
|
||||||
def params
|
def params
|
||||||
Hash.new.merge(token: user.gitea_token, data: body)
|
Hash.new.merge(token: token, data: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/repos/#{user.login}/#{repo_name}/contents/#{filepath}".freeze
|
"/repos/#{owner}/#{repo_name}/contents/#{filepath}".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Gitea::Repository::Entries::UpdateService < Gitea::ClientService
|
class Gitea::Repository::Entries::UpdateService < Gitea::ClientService
|
||||||
attr_reader :user, :repo_name, :filepath, :body
|
attr_reader :token, :owner, :repo_name, :filepath, :body
|
||||||
|
|
||||||
# ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master)
|
# ref: The name of the commit/branch/tag. Default the repository’s default branch (usually master)
|
||||||
# filepath: path of the dir, file, symlink or submodule in the repo
|
# filepath: path of the dir, file, symlink or submodule in the repo
|
||||||
|
@ -20,8 +20,9 @@ class Gitea::Repository::Entries::UpdateService < Gitea::ClientService
|
||||||
# "new_branch": "string"
|
# "new_branch": "string"
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
def initialize(user, repo_name, filepath, body)
|
def initialize(token, owner, repo_name, filepath, body)
|
||||||
@user = user
|
@token = token
|
||||||
|
@owner = owner
|
||||||
@repo_name = repo_name
|
@repo_name = repo_name
|
||||||
@filepath = filepath
|
@filepath = filepath
|
||||||
@body = body
|
@body = body
|
||||||
|
@ -33,11 +34,11 @@ class Gitea::Repository::Entries::UpdateService < Gitea::ClientService
|
||||||
|
|
||||||
private
|
private
|
||||||
def params
|
def params
|
||||||
Hash.new.merge(token: user.gitea_token, data: body)
|
Hash.new.merge(token: token, data: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
"/repos/#{user.login}/#{repo_name}/contents/#{filepath}".freeze
|
"/repos/#{owner}/#{repo_name}/contents/#{filepath}".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,7 @@ json.fork_info do
|
||||||
if @fork_project.present?
|
if @fork_project.present?
|
||||||
json.fork_form_name @fork_project.try(:name)
|
json.fork_form_name @fork_project.try(:name)
|
||||||
json.fork_project_user_login @fork_project_user.try(:login)
|
json.fork_project_user_login @fork_project_user.try(:login)
|
||||||
|
json.fork_project_identifier @fork_project.identifier
|
||||||
json.fork_project_user_name @fork_project_user.try(:show_real_name)
|
json.fork_project_user_name @fork_project_user.try(:show_real_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -259,7 +259,7 @@ Rails.application.routes.draw do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :projects, path: '/', except: [:show] do
|
resource :projects, path: '/', except: [:show, :edit] do
|
||||||
member do
|
member do
|
||||||
get :branches
|
get :branches
|
||||||
get :simple
|
get :simple
|
||||||
|
|
Loading…
Reference in New Issue