Read about our upcoming Code of Conduct on this issue

Commit ced56641 authored by James Lopez's avatar James Lopez
Browse files

refactored code based on feedback

parent a1a2a339724a
...@@ -406,8 +406,7 @@ def clear_import_data ...@@ -406,8 +406,7 @@ def clear_import_data
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 @@ def import_url ...@@ -420,6 +419,13 @@ def import_url
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 @@ def full_url ...@@ -20,10 +20,10 @@ def full_url
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