diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 25d7b2a15..6b41e39fc 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -38,7 +38,7 @@ class RepositoriesController < ApplicationController before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive, :quality_analysis] # 链接gitlab - before_filter :connect_gitlab, :only => [:quality_analysis, :show] + before_filter :connect_gitlab, :only => [:quality_analysis, :show, :commit_diff, :find_project_repository] # 版本库新增权限 before_filter :show_rep, :only => [:show] accept_rss_auth :revisions @@ -48,8 +48,7 @@ class RepositoriesController < ApplicationController include RepositoriesHelper helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH - $g=Gitlab.client - # require 'net/ssh' + require 'net/ssh' rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new @@ -548,8 +547,8 @@ update # 每次提交对应的文件差异 def commit_diff - @commit_diff = $g.commit_diff(@project.gpid, params[:changeset]) - @commit_details = $g.commit(@project.gpid, params[:changeset]) + @commit_diff = @g.commit_diff(@project.gpid, params[:changeset]) + @commit_details = @g.commit(@project.gpid, params[:changeset]) render :layout => 'base_projects' end @@ -700,7 +699,8 @@ update (render_404; return false) unless @repository @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s # gitlab端获取默认分支 - gitlab_branchs = $g.project(@project.gpid).default_branch + g = Gitlab.client + gitlab_branchs = g.project(@project.gpid).default_branch @project.gpid.nil? ? (@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip) : (@rev = params[:rev].blank? ? gitlab_branchs : params[:rev].to_s.strip) @rev_to = params[:rev_to] unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)