Commit ced56641 authored by James Lopez's avatar James Lopez

refactored code based on feedback

parent 6dfb5d7c
...@@ -406,8 +406,7 @@ class Project < ActiveRecord::Base ...@@ -406,8 +406,7 @@ class Project < ActiveRecord::Base
def import_url=(value) def import_url=(value)
import_url = Gitlab::ImportUrl.new(value) import_url = Gitlab::ImportUrl.new(value)
# deletes any existing import_data create_or_update_import_data(import_url.credentials)
create_import_data(credentials: import_url.credentials)
super(import_url.sanitized_url) super(import_url.sanitized_url)
end end
...@@ -420,6 +419,13 @@ class Project < ActiveRecord::Base ...@@ -420,6 +419,13 @@ class Project < ActiveRecord::Base
end end
end end
def create_or_update_import_data(credentials)
project_import_data = import_data || ProjectImportData.new
project_import_data.credentials = credentials
project_import_data.project_id = id
project_import_data.save
end
def import? def import?
external_import? || forked? external_import? || forked?
end end
......
...@@ -20,10 +20,10 @@ module Gitlab ...@@ -20,10 +20,10 @@ module Gitlab
private private
def generate_full_url def generate_full_url
return @url unless @credentials return @url unless credentials
@full_url = @url.dup @full_url = @url.dup
@full_url.user = @credentials[:user] @full_url.user = credentials[:user]
@full_url.password = @credentials[:password] @full_url.password = credentials[:password]
@full_url @full_url
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment