diff options
author | James Lopez <james@jameslopez.es> | 2016-04-07 15:08:38 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-04-07 15:08:38 +0200 |
commit | a1a1d1f7de71f46787f12f1efa23346a2a6b1c29 (patch) | |
tree | 3b68596379b7e025c7964b27461c6baec7bedd8d /app/models | |
parent | 15044e7d857138b31199b796f02a81f0c29c643f (diff) | |
download | gitlab-ce-a1a1d1f7de71f46787f12f1efa23346a2a6b1c29.tar.gz |
refactored create_or_update_import_data
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 17b971b9d30..273b04c6323 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -404,7 +404,7 @@ class Project < ActiveRecord::Base def import_url=(value) import_url = Gitlab::ImportUrl.new(value) - create_or_update_import_data(import_url.credentials) + create_or_update_import_data(credentials: import_url.credentials) super(import_url.sanitized_url) end @@ -417,26 +417,17 @@ class Project < ActiveRecord::Base end end - def create_or_update_import_data(credentials) + def create_or_update_import_data(data: nil, credentials: nil) project_import_data = import_data || build_import_data - project_import_data.credentials ||= {} - project_import_data.credentials = project_import_data.credentials.merge(credentials) - project_import_data.save - end + project_import_data.data = data if data + if credentials + project_import_data.credentials ||= {} + project_import_data.credentials = project_import_data.credentials.merge(credentials) + end - def create_or_update_import_data(credentials) - project_import_data = import_data || build_import_data - project_import_data.credentials ||= {} - project_import_data.credentials = project_import_data.credentials.merge(credentials) project_import_data.save end - def update_import_data(data: nil, credentials: nil) - import_data.data = data if data - import_data.credentials = import_data.credentials.merge(credentials) if credentials - import_data.save - end - def import? external_import? || forked? end |