summaryrefslogtreecommitdiff
path: root/app/models/project_import_data.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add latest changes from gitlab-org/gitlab@masterGitLab Bot2019-09-131-0/+2
|
* Inherit from ApplicationRecord instead of ActiveRecord::BaseNick Thomas2019-03-281-1/+1
|
* Add clear_credentials method to ProjectImportDataStan Hu2019-01-141-0/+4
| | | | | This backports changes made in https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9134.
* Refactor Project#create_or_update_import_dataYorick Peterse2018-12-111-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In https://gitlab.com/gitlab-org/release/framework/issues/28 we found that this method was changed a lot over the years: 43 times if our calculations were correct. Looking at the method, it had quite a few branches going on: def create_or_update_import_data(data: nil, credentials: nil) return if data.nil? && credentials.nil? project_import_data = import_data || build_import_data if data project_import_data.data ||= {} project_import_data.data = project_import_data.data.merge(data) end if credentials project_import_data.credentials ||= {} project_import_data.credentials = project_import_data.credentials.merge(credentials) end project_import_data end If we turn the || and ||= operators into regular if statements, we can see a bit more clearly that this method has quite a lot of branches in it: def create_or_update_import_data(data: nil, credentials: nil) if data.nil? && credentials.nil? return else project_import_data = if import_data import_data else build_import_data end if data if project_import_data.data # nothing else project_import_data.data = {} end project_import_data.data = project_import_data.data.merge(data) end if credentials if project_import_data.credentials # nothing else project_import_data.credentials = {} end project_import_data.credentials = project_import_data.credentials.merge(credentials) end project_import_data end end The number of if statements and branches here makes it easy to make mistakes. To resolve this, we refactor this code in such a way that we can get rid of all but the first `if data.nil? && credentials.nil?` statement. We can do this by simply sending `to_h` to `nil` in the right places, which removes the need for statements such as `if data`. Since this data gets written to a database, in ProjectImportData we do make sure to not write empty Hash values. This requires an `unless` (which is really a `if !`), but the resulting code is still very easy to read.
* Enable frozen string in app/models/*.rbrepo-forks/gitlab-ce-frozen-string-enable-app-modelsgfyoung2018-07-261-0/+2
| | | | Partially addresses #47424.
* Upgrade to Ruby 2.4.4sh-bump-ruby-2.4Stan Hu2018-05-291-1/+1
| | | | | | | | | | | | Fixes that make this work: * A change in Ruby (https://github.com/ruby/ruby/commit/ce635262f53b760284d56bb1027baebaaec175d1) requires passing in the exact required length for OpenSSL keys and IVs. * Ensure the secrets.yml is generated before any prepended modules are loaded. This is done by renaming the `secret_token.rb` initializer to `01_secret_token.rb`, which is a bit ugly but involves the least impact on other files.
* Backport changes in ↵Nick Thomas2017-08-071-1/+1
| | | | https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2551 to CE
* Rename ActiverecordSerialize copYorick Peterse2017-07-061-1/+1
| | | | | This cop has been renamed to ActiveRecordSerialize to match the way "ActiveRecord" is usually written.
* Added Cop to blacklist the use of serializedocument-not-using-serializeYorick Peterse2017-05-311-1/+1
| | | | | This Cop blacklists the use of ActiveRecord's "serialize" method, except for cases where we already use this.
* add missing attribute to attr_encrypted so it is fully backwards-compatibleJames Lopez2016-06-281-0/+1
|
* Upgrade attr_encrypted and encryptorConnor Shea2016-05-301-1/+2
| | | | | | | | | | | | | attr_encrypted (1.3.4 => 3.0.1) Changelog: https://github.com/attr-encrypted/attr_encrypted/blob/master/CHANGELOG.m d attr_encrypted 2.x included a vulnerability, so that major version is skipped. 3.x requires that the algorithm and mode used by each encrypted attribute is specified explicitly. `nil` is no longer a valid value for the encrypted_value_iv field, so it’s changed to a randomly generated string.
* Remove the annotate gem and delete old annotationsJeroen van Baarsen2016-05-091-12/+0
| | | | | | | | | In 8278b763d96ef10c6494409b18b7eb541463af29 the default behaviour of annotation has changes, which was causing a lot of noise in diffs. We decided in #17382 that it is better to get rid of the whole annotate gem, and instead let people look at schema.rb for the columns in a table. Fixes: #17382
* Annotate modelsDmitriy Zaporozhets2016-05-061-2/+2
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
* Annotate the modelsZeger-Jan van de Weg2016-05-061-3/+6
|
* Remove useless require 'file_size_validator' causing warningsRémy Coutable2016-04-191-1/+0
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* changed a few things based on feedbackJames Lopez2016-04-111-2/+6
|
* removed TODO [ci skip]James Lopez2016-04-061-1/+0
|
* fix some issues with credentialsJames Lopez2016-04-061-2/+2
|
* some refactoring to symbolise keys across importers and left a TODOJames Lopez2016-04-051-2/+6
|
* fix fogbugz importJames Lopez2016-04-011-0/+4
|
* fixed some rubocop warningsJames Lopez2016-03-211-1/+1
|
* fixed few issues with the migrationJames Lopez2016-03-211-1/+1
|
* refactored a bunch of stuff based on MR feedbackJames Lopez2016-03-071-1/+1
|
* fix specsJames Lopez2016-03-041-2/+1
|
* added import url exposer to construct URL withunencrypted credentialsJames Lopez2016-03-041-0/+1
|
* WIP - refactored migration and updated project_import_data with encrypted attJames Lopez2016-03-031-1/+2
|
* Re-annotate modelsStan Hu2015-05-031-4/+4
|
* Move import data out of project so it doesn't take ages to load.Douwe Maan2015-04-171-0/+19