From 1a549eda4667a12a0019c760519474c54a73110c Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 21 Dec 2015 14:33:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/repository.rb | 2 +- lib/redmine/scm/adapters/abstract_adapter.rb | 2 +- lib/redmine/scm/adapters/gitlab_adapter.rb | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/repository.rb b/app/models/repository.rb index f50f37f31..571bba1b9 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -107,7 +107,7 @@ class Repository < ActiveRecord::Base def scm unless @scm @scm = self.scm_adapter.new(url, root_url, - login, password, path_encoding) + login, password, path_encoding, project_id) if root_url.blank? && @scm.root_url.present? update_attribute(:root_url, @scm.root_url) end diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 3e51f2d4d..2dd520b92 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -80,7 +80,7 @@ module Redmine end def initialize(url, root_url=nil, login=nil, password=nil, - path_encoding=nil) + path_encoding=nil, project_id) @url = url @login = login if login && !login.empty? @password = (password || "") if @login diff --git a/lib/redmine/scm/adapters/gitlab_adapter.rb b/lib/redmine/scm/adapters/gitlab_adapter.rb index 32429fe35..7b2d18310 100644 --- a/lib/redmine/scm/adapters/gitlab_adapter.rb +++ b/lib/redmine/scm/adapters/gitlab_adapter.rb @@ -13,10 +13,12 @@ module Redmine attr_accessor :is_default end - def initialize(url, root_url=nil, login=nil, password=nil, path_encoding=nil) + def initialize(url, root_url=nil, login=nil, password=nil, path_encoding=nil, project_id) super @g = Gitlab.client - @project = Repository.find_by_url(url).project.gpid + r = Repository.where("url =? and project_id =?", url, project_id).first + @project = r.project.gpid + # @project = Repository.find_by_url(url).project.gpid @path_encoding = path_encoding.blank? ? 'UTF-8' : path_encoding end