summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-03-21 18:09:47 +0100
committerJames Lopez <james@jameslopez.es>2016-03-21 18:09:47 +0100
commitced56641bfc42c8380af1760fae93ba37bf2e785 (patch)
tree8c91a0c6a5cc33dc2764b3859a096a7f5860d9a2 /app
parent6dfb5d7cad3e3cefd766e30a4c25a9549fa2b041 (diff)
downloadgitlab-ce-ced56641bfc42c8380af1760fae93ba37bf2e785.tar.gz
refactored code based on feedback
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 242ad19b115..a1aa1d5fdbc 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -406,8 +406,7 @@ class Project < ActiveRecord::Base
def import_url=(value)
import_url = Gitlab::ImportUrl.new(value)
- # deletes any existing import_data
- create_import_data(credentials: import_url.credentials)
+ create_or_update_import_data(import_url.credentials)
super(import_url.sanitized_url)
end
@@ -420,6 +419,13 @@ class Project < ActiveRecord::Base
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?
external_import? || forked?
end