修改获取分支

dev_forge
sylor_huang@126.com 5 years ago
parent 8859cde4e9
commit 536d53763f

@ -327,8 +327,8 @@ class ApplicationController < ActionController::Base
end end
def current_user def current_user
# User.current User.current
User.find_by_id 50207 # User.find_by_id 50207
# nil # nil
end end

@ -1,7 +1,7 @@
class IssuesController < ApplicationController class IssuesController < ApplicationController
before_action :require_login, except: [:index, :show] before_action :require_login, except: [:index, :show]
before_action :find_project # before_action :find_project
before_action :set_user before_action :set_project_and_user
before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue] before_action :check_project_public, only: [:index ,:show, :copy, :index_chosen, :close_issue]
before_action :check_issue_permission, except: [:index, :show, :index_chosen] before_action :check_issue_permission, except: [:index, :show, :index_chosen]
before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue] before_action :set_issue, only: [:edit, :update, :destroy, :show, :copy, :close_issue, :lock_issue]
@ -127,10 +127,7 @@ class IssuesController < ApplicationController
def new def new
@all_branches = [] @all_branches = []
get_all_branches = Gitea::Repository::BranchesService.new(@project.owner, @project.repository.identifier).call get_all_branches = Gitea::Repository::BranchesService.new(@user, @project&.repository.try(:identifier)).call
Rails.logger.info("######____________###########{@project.owner.login}")
Rails.logger.info("######____________###########{@user.login}")
Rails.logger.info("######_____@project.repository.identifier_______###########{@project.repository.identifier}")
if get_all_branches && get_all_branches.size > 0 if get_all_branches && get_all_branches.size > 0
get_all_branches.each do |b| get_all_branches.each do |b|
@all_branches.push(b["name"]) @all_branches.push(b["name"])
@ -345,8 +342,10 @@ class IssuesController < ApplicationController
end end
private private
def set_user def set_project_and_user
@user = @project.owner @project = Project.find_by_identifier(params[:project_id]) || (Project.find params[:project_id]) || (Project.find params[:id])
@user = @project&.owner
normal_status(-1, "项目不存在") unless @project.present?
normal_status(-1, "用户不存在") unless @user.present? normal_status(-1, "用户不存在") unless @user.present?
end end

Loading…
Cancel
Save