summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
committerToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
commit62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch)
treec3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /lib/tasks
parentf6453eca992a9c142268e78ac782cef98110d183 (diff)
downloadgitlab-ce-tc-standard-gem.tar.gz
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I decided to try https://github.com/testdouble/standard on our codebase. It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/brakeman.rake8
-rw-r--r--lib/tasks/cache.rake4
-rw-r--r--lib/tasks/ci/cleanup.rake2
-rw-r--r--lib/tasks/config_lint.rake12
-rw-r--r--lib/tasks/dev.rake2
-rw-r--r--lib/tasks/downtime_check.rake12
-rw-r--r--lib/tasks/ee_compat_check.rake4
-rw-r--r--lib/tasks/eslint.rake6
-rw-r--r--lib/tasks/gemojione.rake86
-rw-r--r--lib/tasks/gettext.rake44
-rw-r--r--lib/tasks/gitlab/artifacts/check.rake2
-rw-r--r--lib/tasks/gitlab/artifacts/migrate.rake19
-rw-r--r--lib/tasks/gitlab/assets.rake22
-rw-r--r--lib/tasks/gitlab/backup.rake56
-rw-r--r--lib/tasks/gitlab/check.rake14
-rw-r--r--lib/tasks/gitlab/cleanup.rake33
-rw-r--r--lib/tasks/gitlab/db.rake26
-rw-r--r--lib/tasks/gitlab/dev.rake12
-rw-r--r--lib/tasks/gitlab/exclusive_lease.rake4
-rw-r--r--lib/tasks/gitlab/git.rake3
-rw-r--r--lib/tasks/gitlab/gitaly.rake13
-rw-r--r--lib/tasks/gitlab/helpers.rake2
-rw-r--r--lib/tasks/gitlab/import.rake2
-rw-r--r--lib/tasks/gitlab/import_export.rake10
-rw-r--r--lib/tasks/gitlab/info.rake22
-rw-r--r--lib/tasks/gitlab/ldap.rake24
-rw-r--r--lib/tasks/gitlab/lfs/check.rake2
-rw-r--r--lib/tasks/gitlab/lfs/migrate.rake15
-rw-r--r--lib/tasks/gitlab/list_repos.rake10
-rw-r--r--lib/tasks/gitlab/pages.rake2
-rw-r--r--lib/tasks/gitlab/setup.rake10
-rw-r--r--lib/tasks/gitlab/shell.rake53
-rw-r--r--lib/tasks/gitlab/storage.rake42
-rw-r--r--lib/tasks/gitlab/tcp_check.rake2
-rw-r--r--lib/tasks/gitlab/test.rake10
-rw-r--r--lib/tasks/gitlab/traces.rake19
-rw-r--r--lib/tasks/gitlab/track_deployment.rake4
-rw-r--r--lib/tasks/gitlab/two_factor.rake4
-rw-r--r--lib/tasks/gitlab/update_templates.rake6
-rw-r--r--lib/tasks/gitlab/uploads/check.rake2
-rw-r--r--lib/tasks/gitlab/uploads/migrate.rake34
-rw-r--r--lib/tasks/gitlab/web_hook.rake10
-rw-r--r--lib/tasks/gitlab/workhorse.rake4
-rw-r--r--lib/tasks/grape.rake2
-rw-r--r--lib/tasks/haml-lint.rake6
-rw-r--r--lib/tasks/import.rake26
-rw-r--r--lib/tasks/karma.rake18
-rw-r--r--lib/tasks/lint.rake16
-rw-r--r--lib/tasks/migrate/add_limits_mysql.rake12
-rw-r--r--lib/tasks/migrate/composite_primary_keys.rake8
-rw-r--r--lib/tasks/migrate/migrate_iids.rake60
-rw-r--r--lib/tasks/migrate/setup_postgresql.rake34
-rw-r--r--lib/tasks/plugins.rake4
-rw-r--r--lib/tasks/rubocop.rake2
-rw-r--r--lib/tasks/scss-lint.rake4
-rw-r--r--lib/tasks/services.rake78
-rw-r--r--lib/tasks/sidekiq.rake10
-rw-r--r--lib/tasks/spec.rake44
-rw-r--r--lib/tasks/tokens.rake10
-rw-r--r--lib/tasks/yarn.rake37
60 files changed, 516 insertions, 528 deletions
diff --git a/lib/tasks/brakeman.rake b/lib/tasks/brakeman.rake
index 2301ec9b228..284b077f1d3 100644
--- a/lib/tasks/brakeman.rake
+++ b/lib/tasks/brakeman.rake
@@ -1,11 +1,11 @@
-desc 'Security check via brakeman'
+desc "Security check via brakeman"
task :brakeman do
# We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge
# requests are welcome!
- if system(*%w(brakeman --no-progress --skip-files lib/backup/repository.rb -w3 -z))
- puts 'Security check succeed'
+ if system("brakeman", "--no-progress", "--skip-files", "lib/backup/repository.rb", "-w3", "-z")
+ puts "Security check succeed"
else
- puts 'Security check failed'
+ puts "Security check failed"
exit 1
end
end
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake
index cb4d5abffbc..3b2cae9eef5 100644
--- a/lib/tasks/cache.rake
+++ b/lib/tasks/cache.rake
@@ -1,7 +1,7 @@
namespace :cache do
namespace :clear do
REDIS_CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000
- REDIS_SCAN_START_STOP = '0'.freeze # Magic value, see http://redis.io/commands/scan
+ REDIS_SCAN_START_STOP = "0".freeze # Magic value, see http://redis.io/commands/scan
desc "GitLab | Clear redis cache"
task redis: :environment do
@@ -29,5 +29,5 @@ namespace :cache do
task all: [:redis]
end
- task clear: 'cache:clear:redis'
+ task clear: "cache:clear:redis"
end
diff --git a/lib/tasks/ci/cleanup.rake b/lib/tasks/ci/cleanup.rake
index 2f4d11bd942..4ae3754f3ef 100644
--- a/lib/tasks/ci/cleanup.rake
+++ b/lib/tasks/ci/cleanup.rake
@@ -2,7 +2,7 @@ namespace :ci do
namespace :cleanup do
desc "GitLab CI | Clean running builds"
task builds: :environment do
- Ci::Build.running.update_all(status: 'canceled')
+ Ci::Build.running.update_all(status: "canceled")
end
end
end
diff --git a/lib/tasks/config_lint.rake b/lib/tasks/config_lint.rake
index ddbcf1e1eb8..6ebe4374378 100644
--- a/lib/tasks/config_lint.rake
+++ b/lib/tasks/config_lint.rake
@@ -1,8 +1,8 @@
module ConfigLint
def self.run(files)
- failures = files.reject do |file|
+ failures = files.reject { |file|
yield(file)
- end
+ }
if failures.present?
puts failures
@@ -14,12 +14,12 @@ end
desc "Checks syntax for shell scripts and nginx config files in 'lib/support/'"
task :config_lint do
shell_scripts = [
- 'lib/support/init.d/gitlab',
- 'lib/support/init.d/gitlab.default.example',
- 'lib/support/deploy/deploy.sh'
+ "lib/support/init.d/gitlab",
+ "lib/support/init.d/gitlab.default.example",
+ "lib/support/deploy/deploy.sh",
]
ConfigLint.run(shell_scripts) do |file|
- Kernel.system('bash', '-n', file)
+ Kernel.system("bash", "-n", file)
end
end
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index b1db4dc94a6..7b4d55ce9a5 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -3,7 +3,7 @@ task dev: ["dev:setup"]
namespace :dev do
desc "GitLab | Setup developer environment (db, fixtures)"
task setup: :environment do
- ENV['force'] = 'yes'
+ ENV["force"] = "yes"
Rake::Task["gitlab:setup"].invoke
Rake::Task["gitlab:shell:setup"].invoke
end
diff --git a/lib/tasks/downtime_check.rake b/lib/tasks/downtime_check.rake
index 557f4fef10b..b55882a3973 100644
--- a/lib/tasks/downtime_check.rake
+++ b/lib/tasks/downtime_check.rake
@@ -1,12 +1,12 @@
-desc 'Checks if migrations in a branch require downtime'
+desc "Checks if migrations in a branch require downtime"
task downtime_check: :environment do
repo = if defined?(Gitlab::License)
- 'gitlab-ee'
- else
- 'gitlab-ce'
- end
+ "gitlab-ee"
+ else
+ "gitlab-ce"
+ end
`git fetch https://gitlab.com/gitlab-org/#{repo}.git --depth 1`
- Rake::Task['gitlab:db:downtime_check'].invoke('FETCH_HEAD')
+ Rake::Task["gitlab:db:downtime_check"].invoke("FETCH_HEAD")
end
diff --git a/lib/tasks/ee_compat_check.rake b/lib/tasks/ee_compat_check.rake
index f494fa5c5c2..e9f88fad326 100644
--- a/lib/tasks/ee_compat_check.rake
+++ b/lib/tasks/ee_compat_check.rake
@@ -1,4 +1,4 @@
-desc 'Checks if the branch would apply cleanly to EE'
+desc "Checks if the branch would apply cleanly to EE"
task ee_compat_check: :environment do
- Rake::Task['gitlab:dev:ee_compat_check'].invoke
+ Rake::Task["gitlab:dev:ee_compat_check"].invoke
end
diff --git a/lib/tasks/eslint.rake b/lib/tasks/eslint.rake
index 51f5d768102..49d2a8cd821 100644
--- a/lib/tasks/eslint.rake
+++ b/lib/tasks/eslint.rake
@@ -1,8 +1,8 @@
unless Rails.env.production?
desc "GitLab | Run ESLint"
- task eslint: ['yarn:check'] do
- unless system('yarn run eslint')
- abort('rake eslint failed')
+ task eslint: ["yarn:check"] do
+ unless system("yarn run eslint")
+ abort("rake eslint failed")
end
end
end
diff --git a/lib/tasks/gemojione.rake b/lib/tasks/gemojione.rake
index 560a52053d8..e7fc46be9b3 100644
--- a/lib/tasks/gemojione.rake
+++ b/lib/tasks/gemojione.rake
@@ -1,34 +1,34 @@
namespace :gemojione do
- desc 'Generates Emoji SHA256 digests'
+ desc "Generates Emoji SHA256 digests"
- task aliases: ['yarn:check', 'environment'] do
- require 'json'
+ task aliases: ["yarn:check", "environment"] do
+ require "json"
aliases = {}
- index_file = File.join(Rails.root, 'fixtures', 'emojis', 'index.json')
+ index_file = File.join(Rails.root, "fixtures", "emojis", "index.json")
index = JSON.parse(File.read(index_file))
index.each_pair do |key, data|
- data['aliases'].each do |a|
- a.tr!(':', '')
+ data["aliases"].each do |a|
+ a.tr!(":", "")
aliases[a] = key
end
end
- out = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json')
- File.open(out, 'w') do |handle|
- handle.write(JSON.pretty_generate(aliases, indent: ' ', space: '', space_before: ''))
+ out = File.join(Rails.root, "fixtures", "emojis", "aliases.json")
+ File.open(out, "w") do |handle|
+ handle.write(JSON.pretty_generate(aliases, indent: " ", space: "", space_before: ""))
end
end
- task digests: ['yarn:check', 'environment'] do
- require 'digest/sha2'
- require 'json'
+ task digests: ["yarn:check", "environment"] do
+ require "digest/sha2"
+ require "json"
# We don't have `node_modules` available in built versions of GitLab
- FileUtils.cp_r(Rails.root.join('node_modules', 'emoji-unicode-version', 'emoji-unicode-version-map.json'), File.join(Rails.root, 'fixtures', 'emojis'))
+ FileUtils.cp_r(Rails.root.join("node_modules", "emoji-unicode-version", "emoji-unicode-version-map.json"), File.join(Rails.root, "fixtures", "emojis"))
dir = Gemojione.images_path
resultant_emoji_map = {}
@@ -36,28 +36,28 @@ namespace :gemojione do
Gitlab::Emoji.emojis.each do |name, emoji_hash|
# Ignore aliases
unless Gitlab::Emoji.emojis_aliases.key?(name)
- fpath = File.join(dir, "#{emoji_hash['unicode']}.png")
+ fpath = File.join(dir, "#{emoji_hash["unicode"]}.png")
hash_digest = Digest::SHA256.file(fpath).hexdigest
- category = emoji_hash['category']
- if name == 'gay_pride_flag'
- category = 'flags'
+ category = emoji_hash["category"]
+ if name == "gay_pride_flag"
+ category = "flags"
end
entry = {
category: category,
- moji: emoji_hash['moji'],
- description: emoji_hash['description'],
+ moji: emoji_hash["moji"],
+ description: emoji_hash["description"],
unicodeVersion: Gitlab::Emoji.emoji_unicode_version(name),
- digest: hash_digest
+ digest: hash_digest,
}
resultant_emoji_map[name] = entry
end
end
- out = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json')
- File.open(out, 'w') do |handle|
+ out = File.join(Rails.root, "fixtures", "emojis", "digests.json")
+ File.open(out, "w") do |handle|
handle.write(JSON.pretty_generate(resultant_emoji_map))
end
end
@@ -70,8 +70,8 @@ namespace :gemojione do
# occasionally, such as when new Emojis are added to Gemojione.
task sprite: :environment do
begin
- require 'sprite_factory'
- require 'rmagick'
+ require "sprite_factory"
+ require "rmagick"
rescue LoadError
# noop
end
@@ -91,22 +91,22 @@ namespace :gemojione do
Gitlab::Emoji.emojis.each do |name, emoji_hash|
# Ignore aliases
unless Gitlab::Emoji.emojis_aliases.key?(name)
- emoji_unicode_string_to_name_map[emoji_hash['unicode']] = name
+ emoji_unicode_string_to_name_map[emoji_hash["unicode"]] = name
end
end
# Copy the Gemojione assets to the temporary folder for renaming
emoji_dir = "app/assets/images/emoji"
FileUtils.rm_rf(emoji_dir)
- FileUtils.mkdir_p(emoji_dir, mode: 0700)
- FileUtils.cp_r(File.join(Gemojione.images_path, '.'), emoji_dir)
+ FileUtils.mkdir_p(emoji_dir, mode: 0o700)
+ FileUtils.cp_r(File.join(Gemojione.images_path, "."), emoji_dir)
Dir[File.join(emoji_dir, "**/*.png")].each do |png|
image_path = png
rename_to_named_emoji_image!(emoji_unicode_string_to_name_map, image_path)
end
Dir.mktmpdir do |tmpdir|
- FileUtils.cp_r(File.join(emoji_dir, '.'), tmpdir)
+ FileUtils.cp_r(File.join(emoji_dir, "."), tmpdir)
Dir.chdir(tmpdir) do
Dir["**/*.png"].each do |png|
@@ -115,28 +115,28 @@ namespace :gemojione do
end
end
- style_path = Rails.root.join(*%w(app assets stylesheets framework emoji_sprites.scss))
+ style_path = Rails.root.join("app", "assets", "stylesheets", "framework", "emoji_sprites.scss")
# Combine the resized assets into a packed sprite and re-generate the SCSS
SpriteFactory.cssurl = "image-url('$IMAGE')"
SpriteFactory.run!(tmpdir, {
output_style: style_path,
output_image: "app/assets/images/emoji.png",
- selector: '.emoji-',
- style: :scss,
- nocomments: true,
- pngcrush: true,
- layout: :packed
+ selector: ".emoji-",
+ style: :scss,
+ nocomments: true,
+ pngcrush: true,
+ layout: :packed,
})
# SpriteFactory's SCSS is a bit too verbose for our purposes here, so
# let's simplify it
- system(%Q(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
- system(%Q(sed -i '' "s/ no-repeat//" #{style_path}))
- system(%Q(sed -i '' "s/ 0px/ 0/g" #{style_path}))
+ system(%(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
+ system(%(sed -i '' "s/ no-repeat//" #{style_path}))
+ system(%(sed -i '' "s/ 0px/ 0/g" #{style_path}))
# Append a generic rule that applies to all Emojis
- File.open(style_path, 'a') do |f|
+ File.open(style_path, "a") do |f|
f.puts
f.puts <<-CSS.strip_heredoc
.emoji-icon {
@@ -164,7 +164,7 @@ namespace :gemojione do
# Now do it again but for Retina
Dir.mktmpdir do |tmpdir|
# Copy the Gemojione assets to the temporary folder for resizing
- FileUtils.cp_r(File.join(emoji_dir, '.'), tmpdir)
+ FileUtils.cp_r(File.join(emoji_dir, "."), tmpdir)
Dir.chdir(tmpdir) do
Dir["**/*.png"].each do |png|
@@ -176,10 +176,10 @@ namespace :gemojione do
# Combine the resized assets into a packed sprite and re-generate the SCSS
SpriteFactory.run!(tmpdir, {
output_image: "app/assets/images/emoji@2x.png",
- style: false,
- nocomments: true,
- pngcrush: true,
- layout: :packed
+ style: false,
+ nocomments: true,
+ pngcrush: true,
+ layout: :packed,
})
end
end
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index 2235a6ba194..81754bb9eeb 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -4,8 +4,8 @@ namespace :gettext do
# Customize list of translatable files
# See: https://github.com/grosser/gettext_i18n_rails#customizing-list-of-translatable-files
def files_to_translate
- folders = %W(ee app lib config #{locale_path}).join(',')
- exts = %w(rb erb haml slim rhtml js jsx vue handlebars hbs mustache).join(',')
+ folders = %W[ee app lib config #{locale_path}].join(",")
+ exts = %w[rb erb haml slim rhtml js jsx vue handlebars hbs mustache].join(",")
Dir.glob(
"{#{folders}}/**/*.{#{exts}}"
@@ -14,55 +14,55 @@ namespace :gettext do
task :compile do
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/33014#note_31218998
- FileUtils.touch(File.join(Rails.root, 'locale/gitlab.pot'))
+ FileUtils.touch(File.join(Rails.root, "locale/gitlab.pot"))
- Rake::Task['gettext:po_to_json'].invoke
+ Rake::Task["gettext:po_to_json"].invoke
end
task :regenerate do
- pot_file = 'locale/gitlab.pot'
+ pot_file = "locale/gitlab.pot"
# Remove all translated files, this speeds up finding
- FileUtils.rm Dir['locale/**/gitlab.*']
+ FileUtils.rm Dir["locale/**/gitlab.*"]
# remove the `pot` file to ensure it's completely regenerated
FileUtils.rm_f pot_file
- Rake::Task['gettext:find'].invoke
+ Rake::Task["gettext:find"].invoke
# leave only the required changes.
`git checkout -- locale/*/gitlab.po`
# Remove timestamps from the pot file
pot_content = File.read pot_file
- pot_content.gsub!(/^"POT?\-(?:Creation|Revision)\-Date\:.*\n/, '')
+ pot_content.gsub!(/^"POT?\-(?:Creation|Revision)\-Date\:.*\n/, "")
File.write pot_file, pot_content
puts <<~MSG
- All done. Please commit the changes to `locale/gitlab.pot`.
+ All done. Please commit the changes to `locale/gitlab.pot`.
MSG
end
- desc 'Lint all po files in `locale/'
+ desc "Lint all po files in `locale/"
task lint: :environment do
- require 'simple_po_parser'
- require 'gitlab/utils'
+ require "simple_po_parser"
+ require "gitlab/utils"
FastGettext.silence_errors
- files = Dir.glob(Rails.root.join('locale/*/gitlab.po'))
+ files = Dir.glob(Rails.root.join("locale/*/gitlab.po"))
- linters = files.map do |file|
+ linters = files.map { |file|
locale = File.basename(File.dirname(file))
Gitlab::I18n::PoLinter.new(file, locale)
- end
+ }
- pot_file = Rails.root.join('locale/gitlab.pot')
+ pot_file = Rails.root.join("locale/gitlab.pot")
linters.unshift(Gitlab::I18n::PoLinter.new(pot_file))
failed_linters = linters.select { |linter| linter.errors.any? }
if failed_linters.empty?
- puts 'All PO files are valid.'
+ puts "All PO files are valid."
else
failed_linters.each do |linter|
report_errors_for_file(linter.po_path, linter.errors)
@@ -73,17 +73,17 @@ namespace :gettext do
end
task :updated_check do
- pot_file = 'locale/gitlab.pot'
+ pot_file = "locale/gitlab.pot"
# Removing all pre-translated files speeds up `gettext:find` as the
# files don't need to be merged.
# Having `LC_MESSAGES/gitlab.mo files present also confuses the output.
- FileUtils.rm Dir['locale/**/gitlab.*']
+ FileUtils.rm Dir["locale/**/gitlab.*"]
FileUtils.rm_f pot_file
# `gettext:find` writes touches to temp files to `stderr` which would cause
# `static-analysis` to report failures. We can ignore these.
silence_stderr do
- Rake::Task['gettext:find'].invoke
+ Rake::Task["gettext:find"].invoke
end
pot_diff = `git diff -- #{pot_file} | grep -E '^(\\+|-)msgid'`.strip
@@ -112,8 +112,8 @@ namespace :gettext do
errors_for_file.each do |message_id, errors|
puts " #{message_id}"
errors.each do |error|
- spaces = ' ' * 4
- error = error.lines.join("#{spaces}")
+ spaces = " " * 4
+ error = error.lines.join(spaces.to_s)
puts "#{spaces}#{error}"
end
end
diff --git a/lib/tasks/gitlab/artifacts/check.rake b/lib/tasks/gitlab/artifacts/check.rake
index a105261ed51..662204b650c 100644
--- a/lib/tasks/gitlab/artifacts/check.rake
+++ b/lib/tasks/gitlab/artifacts/check.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :artifacts do
- desc 'GitLab | Artifacts | Check integrity of uploaded job artifacts'
+ desc "GitLab | Artifacts | Check integrity of uploaded job artifacts"
task check: :environment do
Gitlab::Verify::RakeTask.run!(Gitlab::Verify::JobArtifacts)
end
diff --git a/lib/tasks/gitlab/artifacts/migrate.rake b/lib/tasks/gitlab/artifacts/migrate.rake
index e7634d2ed4f..3458d6ca5f5 100644
--- a/lib/tasks/gitlab/artifacts/migrate.rake
+++ b/lib/tasks/gitlab/artifacts/migrate.rake
@@ -1,24 +1,23 @@
-require 'logger'
-require 'resolv-replace'
+require "logger"
+require "resolv-replace"
desc "GitLab | Migrate files for artifacts to comply with new storage format"
namespace :gitlab do
namespace :artifacts do
task migrate: :environment do
logger = Logger.new(STDOUT)
- logger.info('Starting transfer of artifacts')
+ logger.info("Starting transfer of artifacts")
Ci::Build.joins(:project)
.with_artifacts_stored_locally
.find_each(batch_size: 10) do |build|
- begin
- build.artifacts_file.migrate!(ObjectStorage::Store::REMOTE)
- build.artifacts_metadata.migrate!(ObjectStorage::Store::REMOTE)
- logger.info("Transferred artifact ID #{build.id} with size #{build.artifacts_size} to object storage")
- rescue => e
- logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
- end
+ build.artifacts_file.migrate!(ObjectStorage::Store::REMOTE)
+ build.artifacts_metadata.migrate!(ObjectStorage::Store::REMOTE)
+
+ logger.info("Transferred artifact ID #{build.id} with size #{build.artifacts_size} to object storage")
+ rescue => e
+ logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
end
end
end
diff --git a/lib/tasks/gitlab/assets.rake b/lib/tasks/gitlab/assets.rake
index 7a42e4e92a0..9d425af8266 100644
--- a/lib/tasks/gitlab/assets.rake
+++ b/lib/tasks/gitlab/assets.rake
@@ -1,8 +1,8 @@
namespace :gitlab do
namespace :assets do
- desc 'GitLab | Assets | Compile all frontend assets'
+ desc "GitLab | Assets | Compile all frontend assets"
task :compile do
- require_dependency 'gitlab/task_helpers'
+ require_dependency "gitlab/task_helpers"
%w[
yarn:check
@@ -13,18 +13,18 @@ namespace :gitlab do
].each(&Gitlab::TaskHelpers.method(:invoke_and_time_task))
end
- desc 'GitLab | Assets | Clean up old compiled frontend assets'
- task clean: ['rake:assets:clean']
+ desc "GitLab | Assets | Clean up old compiled frontend assets"
+ task clean: ["rake:assets:clean"]
- desc 'GitLab | Assets | Remove all compiled frontend assets'
- task purge: ['rake:assets:clobber']
+ desc "GitLab | Assets | Remove all compiled frontend assets"
+ task purge: ["rake:assets:clobber"]
- desc 'GitLab | Assets | Uninstall frontend dependencies'
- task purge_modules: ['yarn:clobber']
+ desc "GitLab | Assets | Uninstall frontend dependencies"
+ task purge_modules: ["yarn:clobber"]
- desc 'GitLab | Assets | Fix all absolute url references in CSS'
+ desc "GitLab | Assets | Fix all absolute url references in CSS"
task :fix_urls do
- css_files = Dir['public/assets/*.css']
+ css_files = Dir["public/assets/*.css"]
css_files.each do |file|
# replace url(/assets/*) with url(./*)
puts "Fixing #{file}"
@@ -38,7 +38,7 @@ namespace :gitlab do
FileUtils.rm(gzip)
mtime = File.stat(file).mtime
- File.open(gzip, 'wb+') do |f|
+ File.open(gzip, "wb+") do |f|
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
gz.mtime = mtime
gz.write IO.binread(file)
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake
index 3a1a36e36ce..1204dd2195c 100644
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -1,4 +1,4 @@
-require 'active_record/fixtures'
+require "active_record/fixtures"
namespace :gitlab do
namespace :backup do
@@ -23,16 +23,16 @@ namespace :gitlab do
end
# Restore backup of GitLab system
- desc 'GitLab | Restore a previously created backup'
+ desc "GitLab | Restore a previously created backup"
task restore: :gitlab_environment do
warn_user_is_not_gitlab
backup = Backup::Manager.new(progress)
backup.unpack
- unless backup.skipped?('db')
+ unless backup.skipped?("db")
begin
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
warning = <<-MSG.strip_heredoc
Before restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
@@ -41,31 +41,31 @@ namespace :gitlab do
MSG
puts warning.color(:red)
ask_to_continue
- puts 'Removing all tables. Press `Ctrl-C` within 5 seconds to abort'.color(:yellow)
+ puts "Removing all tables. Press `Ctrl-C` within 5 seconds to abort".color(:yellow)
sleep(5)
end
# Drop all tables Load the schema to ensure we don't have any newer tables
# hanging out from a failed upgrade
- puts_time 'Cleaning the database ... '.color(:blue)
- Rake::Task['gitlab:db:drop_tables'].invoke
- puts_time 'done'.color(:green)
- Rake::Task['gitlab:backup:db:restore'].invoke
+ puts_time "Cleaning the database ... ".color(:blue)
+ Rake::Task["gitlab:db:drop_tables"].invoke
+ puts_time "done".color(:green)
+ Rake::Task["gitlab:backup:db:restore"].invoke
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".color(:red)
exit 1
end
end
- Rake::Task['gitlab:backup:repo:restore'].invoke unless backup.skipped?('repositories')
- Rake::Task['gitlab:backup:uploads:restore'].invoke unless backup.skipped?('uploads')
- Rake::Task['gitlab:backup:builds:restore'].invoke unless backup.skipped?('builds')
- Rake::Task['gitlab:backup:artifacts:restore'].invoke unless backup.skipped?('artifacts')
- Rake::Task["gitlab:backup:pages:restore"].invoke unless backup.skipped?('pages')
- Rake::Task['gitlab:backup:lfs:restore'].invoke unless backup.skipped?('lfs')
- Rake::Task['gitlab:backup:registry:restore'].invoke unless backup.skipped?('registry')
- Rake::Task['gitlab:shell:setup'].invoke
- Rake::Task['cache:clear'].invoke
+ Rake::Task["gitlab:backup:repo:restore"].invoke unless backup.skipped?("repositories")
+ Rake::Task["gitlab:backup:uploads:restore"].invoke unless backup.skipped?("uploads")
+ Rake::Task["gitlab:backup:builds:restore"].invoke unless backup.skipped?("builds")
+ Rake::Task["gitlab:backup:artifacts:restore"].invoke unless backup.skipped?("artifacts")
+ Rake::Task["gitlab:backup:pages:restore"].invoke unless backup.skipped?("pages")
+ Rake::Task["gitlab:backup:lfs:restore"].invoke unless backup.skipped?("lfs")
+ Rake::Task["gitlab:backup:registry:restore"].invoke unless backup.skipped?("registry")
+ Rake::Task["gitlab:shell:setup"].invoke
+ Rake::Task["cache:clear"].invoke
backup.cleanup
end
@@ -74,7 +74,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping repositories ...".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("repositories")
+ if ENV["SKIP"]&.include?("repositories")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Repository.new(progress).dump
@@ -93,7 +93,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping database ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("db")
+ if ENV["SKIP"]&.include?("db")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Database.new(progress).dump
@@ -112,7 +112,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping builds ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("builds")
+ if ENV["SKIP"]&.include?("builds")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Builds.new(progress).dump
@@ -131,7 +131,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping uploads ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("uploads")
+ if ENV["SKIP"]&.include?("uploads")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Uploads.new(progress).dump
@@ -150,7 +150,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping artifacts ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("artifacts")
+ if ENV["SKIP"]&.include?("artifacts")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Artifacts.new(progress).dump
@@ -169,7 +169,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping pages ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("pages")
+ if ENV["SKIP"]&.include?("pages")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Pages.new(progress).dump
@@ -188,7 +188,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping lfs objects ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("lfs")
+ if ENV["SKIP"]&.include?("lfs")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Lfs.new(progress).dump
@@ -208,7 +208,7 @@ namespace :gitlab do
puts_time "Dumping container registry images ... ".color(:blue)
if Gitlab.config.registry.enabled
- if ENV["SKIP"] && ENV["SKIP"].include?("registry")
+ if ENV["SKIP"]&.include?("registry")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Registry.new(progress).dump
@@ -236,10 +236,10 @@ namespace :gitlab do
end
def progress
- if ENV['CRON']
+ if ENV["CRON"]
# We need an object we can say 'puts' and 'print' to; let's use a
# StringIO.
- require 'stringio'
+ require "stringio"
StringIO.new
else
$stdout
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index b594f150c3b..365c8b674a1 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -1,11 +1,11 @@
namespace :gitlab do
- desc 'GitLab | Check the configuration of GitLab and its environment'
+ desc "GitLab | Check the configuration of GitLab and its environment"
task check: :gitlab_environment do
SystemCheck::RakeTask::GitlabTask.run!
end
namespace :app do
- desc 'GitLab | Check the configuration of the GitLab Rails app'
+ desc "GitLab | Check the configuration of the GitLab Rails app"
task check: :gitlab_environment do
SystemCheck::RakeTask::AppTask.run!
end
@@ -19,7 +19,7 @@ namespace :gitlab do
end
namespace :gitaly do
- desc 'GitLab | Check the health of Gitaly'
+ desc "GitLab | Check the health of Gitaly"
task check: :gitlab_environment do
SystemCheck::RakeTask::GitalyTask.run!
end
@@ -41,24 +41,24 @@ namespace :gitlab do
namespace :ldap do
task :check, [:limit] => :gitlab_environment do |_, args|
- ENV['LDAP_CHECK_LIMIT'] = args.limit if args.limit.present?
+ ENV["LDAP_CHECK_LIMIT"] = args.limit if args.limit.present?
SystemCheck::RakeTask::LdapTask.run!
end
end
namespace :orphans do
- desc 'Gitlab | Check for orphaned namespaces and repositories'
+ desc "Gitlab | Check for orphaned namespaces and repositories"
task check: :gitlab_environment do
SystemCheck::RakeTask::OrphansTask.run!
end
- desc 'GitLab | Check for orphaned namespaces in the repositories path'
+ desc "GitLab | Check for orphaned namespaces in the repositories path"
task check_namespaces: :gitlab_environment do
SystemCheck::RakeTask::Orphans::NamespaceTask.run!
end
- desc 'GitLab | Check for orphaned repositories in the repositories path'
+ desc "GitLab | Check for orphaned repositories in the repositories path"
task check_repositories: :gitlab_environment do
SystemCheck::RakeTask::Orphans::RepositoryTask.run!
end
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index 451ba651674..3d8b537ecc3 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-require 'set'
+
+require "set"
namespace :gitlab do
namespace :cleanup do
@@ -12,7 +13,7 @@ namespace :gitlab do
all_dirs = Gitlab::GitalyClient::StorageService
.new(server.storage)
.list_directories(depth: 0)
- .reject { |dir| dir.ends_with?('.git') || namespaces.include?(File.basename(dir)) }
+ .reject { |dir| dir.ends_with?(".git") || namespaces.include?(File.basename(dir)) }
puts "Looking for directories to remove... "
all_dirs.each do |dir_path|
@@ -22,7 +23,7 @@ namespace :gitlab do
.remove(dir_path)
puts "Removed...#{dir_path}"
- rescue StandardError => e
+ rescue => e
puts "Cannot remove #{dir_path}: #{e.message}".color(:red)
end
else
@@ -45,7 +46,7 @@ namespace :gitlab do
.new(server.storage)
.list_directories
.each do |path|
- repo_with_namespace = path.chomp('.git').chomp('.wiki')
+ repo_with_namespace = path.chomp(".git").chomp(".wiki")
# TODO ignoring hashed repositories for now. But revisit to fully support
# possible orphaned hashed repos
@@ -53,13 +54,13 @@ namespace :gitlab do
next if Project.find_by_full_path(repo_with_namespace)
new_path = path + move_suffix
- puts path.inspect + ' -> ' + new_path.inspect
+ puts path.inspect + " -> " + new_path.inspect
begin
Gitlab::GitalyClient::NamespaceService
.new(server.storage)
.rename(path, new_path)
- rescue StandardError => e
+ rescue => e
puts "Error occured while moving the repository: #{e.message}".color(:red)
end
end
@@ -69,7 +70,7 @@ namespace :gitlab do
desc "GitLab | Cleanup | Block users that have been removed in LDAP"
task block_removed_ldap_users: :gitlab_environment do
warn_user_is_not_gitlab
- block_flag = ENV['BLOCK']
+ block_flag = ENV["BLOCK"]
User.find_each do |user|
next unless user.ldap_user?
@@ -105,7 +106,7 @@ namespace :gitlab do
end
end
- desc 'GitLab | Cleanup | Clean orphan remote upload files that do not exist in the db'
+ desc "GitLab | Cleanup | Clean orphan remote upload files that do not exist in the db"
task remote_upload_files: :environment do
cleaner = Gitlab::Cleanup::RemoteUploads.new(logger: logger)
cleaner.run!(dry_run: dry_run?)
@@ -116,23 +117,23 @@ namespace :gitlab do
end
def remove?
- ENV['REMOVE'] == 'true'
+ ENV["REMOVE"] == "true"
end
def dry_run?
- ENV['DRY_RUN'] != 'false'
+ ENV["DRY_RUN"] != "false"
end
def logger
return @logger if defined?(@logger)
@logger = if Rails.env.development? || Rails.env.production?
- Logger.new(STDOUT).tap do |stdout_logger|
- stdout_logger.extend(ActiveSupport::Logger.broadcast(Rails.logger))
- end
- else
- Rails.logger
- end
+ Logger.new(STDOUT).tap do |stdout_logger|
+ stdout_logger.extend(ActiveSupport::Logger.broadcast(Rails.logger))
+ end
+ else
+ Rails.logger
+ end
end
end
end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index b94b21775ee..0dd6a5b5c29 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :db do
- desc 'GitLab | Manually insert schema migration version'
+ desc "GitLab | Manually insert schema migration version"
task :mark_migration_complete, [:version] => :environment do |_, args|
unless args[:version]
puts "Must specify a migration version as an argument".color(:red)
@@ -22,18 +22,18 @@ namespace :gitlab do
end
end
- desc 'Drop all tables'
+ desc "Drop all tables"
task drop_tables: :environment do
connection = ActiveRecord::Base.connection
# If MySQL, turn off foreign key checks
- connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql?
+ connection.execute("SET FOREIGN_KEY_CHECKS=0") if Gitlab::Database.mysql?
tables = connection.data_sources
# Removes the entry from the array
- tables.delete 'schema_migrations'
+ tables.delete "schema_migrations"
# Truncate schema_migrations to ensure migrations re-run
- connection.execute('TRUNCATE schema_migrations') if connection.data_source_exists? 'schema_migrations'
+ connection.execute("TRUNCATE schema_migrations") if connection.data_source_exists? "schema_migrations"
# Drop tables with cascade to avoid dependent table errors
# PG: http://www.postgresql.org/docs/current/static/ddl-depend.html
@@ -42,28 +42,28 @@ namespace :gitlab do
tables.each { |t| connection.execute("DROP TABLE IF EXISTS #{connection.quote_table_name(t)} CASCADE") }
# If MySQL, re-enable foreign key checks
- connection.execute('SET FOREIGN_KEY_CHECKS=1') if Gitlab::Database.mysql?
+ connection.execute("SET FOREIGN_KEY_CHECKS=1") if Gitlab::Database.mysql?
end
- desc 'Configures the database by running migrate, or by loading the schema and seeding if needed'
+ desc "Configures the database by running migrate, or by loading the schema and seeding if needed"
task configure: :environment do
# Check if we have existing db tables
# The schema_migrations table will still exist if drop_tables was called
if ActiveRecord::Base.connection.tables.count > 1
- Rake::Task['db:migrate'].invoke
+ Rake::Task["db:migrate"].invoke
else
# Add post-migrate paths to ensure we mark all migrations as up
Gitlab::Database.add_post_migrate_path_to_rails(force: true)
- Rake::Task['db:schema:load'].invoke
- Rake::Task['db:seed_fu'].invoke
+ Rake::Task["db:schema:load"].invoke
+ Rake::Task["db:seed_fu"].invoke
end
end
- desc 'Checks if migrations require downtime or not'
+ desc "Checks if migrations require downtime or not"
task :downtime_check, [:ref] => :environment do |_, args|
- abort 'You must specify a Git reference to compare with' unless args[:ref]
+ abort "You must specify a Git reference to compare with" unless args[:ref]
- require 'shellwords'
+ require "shellwords"
ref = Shellwords.escape(args[:ref])
diff --git a/lib/tasks/gitlab/dev.rake b/lib/tasks/gitlab/dev.rake
index 77c28615856..64a7306724e 100644
--- a/lib/tasks/gitlab/dev.rake
+++ b/lib/tasks/gitlab/dev.rake
@@ -1,13 +1,13 @@
namespace :gitlab do
namespace :dev do
- desc 'Checks if the branch would apply cleanly to EE'
+ desc "Checks if the branch would apply cleanly to EE"
task :ee_compat_check, [:branch] => :environment do |_, args|
opts =
- if ENV['CI']
+ if ENV["CI"]
{
- ce_project_url: ENV['CI_PROJECT_URL'],
- branch: ENV['CI_COMMIT_REF_NAME'],
- job_id: ENV['CI_JOB_ID']
+ ce_project_url: ENV["CI_PROJECT_URL"],
+ branch: ENV["CI_COMMIT_REF_NAME"],
+ job_id: ENV["CI_JOB_ID"],
}
else
unless args[:branch]
@@ -18,7 +18,7 @@ namespace :gitlab do
args
end
- if File.basename(Rails.root) == 'gitlab-ee'
+ if File.basename(Rails.root) == "gitlab-ee"
puts "Skipping EE projects"
exit 0
elsif Gitlab::EeCompatCheck.new(opts || {}).check
diff --git a/lib/tasks/gitlab/exclusive_lease.rake b/lib/tasks/gitlab/exclusive_lease.rake
index 83722bf6d94..547d35f9310 100644
--- a/lib/tasks/gitlab/exclusive_lease.rake
+++ b/lib/tasks/gitlab/exclusive_lease.rake
@@ -1,9 +1,9 @@
namespace :gitlab do
namespace :exclusive_lease do
- desc 'GitLab | Clear existing exclusive leases for specified scope (default: *)'
+ desc "GitLab | Clear existing exclusive leases for specified scope (default: *)"
task :clear, [:scope] => [:environment] do |_, args|
args[:scope].nil? ? Gitlab::ExclusiveLease.reset_all! : Gitlab::ExclusiveLease.reset_all!(args[:scope])
- puts 'All exclusive lease entries were removed.'
+ puts "All exclusive lease entries were removed."
end
end
end
diff --git a/lib/tasks/gitlab/git.rake b/lib/tasks/gitlab/git.rake
index 8a53b51d4fe..2924d40d2ce 100644
--- a/lib/tasks/gitlab/git.rake
+++ b/lib/tasks/gitlab/git.rake
@@ -1,12 +1,11 @@
namespace :gitlab do
namespace :git do
- desc 'GitLab | Git | Check all repos integrity'
+ desc "GitLab | Git | Check all repos integrity"
task fsck: :gitlab_environment do
failures = []
Project.find_each(batch_size: 100) do |project|
begin
project.repository.fsck
-
rescue => e
failures << "#{project.full_path} on #{project.repository_storage}: #{e}"
end
diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake
index 80de3d2ef51..c5e1d7084df 100644
--- a/lib/tasks/gitlab/gitaly.rake
+++ b/lib/tasks/gitlab/gitaly.rake
@@ -9,7 +9,7 @@ namespace :gitlab do
Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
end
- args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitaly.git')
+ args.with_defaults(repo: "https://gitlab.com/gitlab-org/gitaly.git")
version = Gitlab::GitalyClient.expected_server_version
@@ -18,19 +18,20 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
command = %w[/usr/bin/env -u RUBYOPT -u BUNDLE_GEMFILE]
_, status = Gitlab::Popen.popen(%w[which gmake])
- command << (status.zero? ? 'gmake' : 'make')
+ command << (status.zero? ? "gmake" : "make")
if Rails.env.test?
command.push(
- 'BUNDLE_FLAGS=--no-deployment',
- "BUNDLE_PATH=#{Bundler.bundle_path}")
+ "BUNDLE_FLAGS=--no-deployment",
+ "BUNDLE_PATH=#{Bundler.bundle_path}"
+ )
end
- storage_paths = { 'default' => args.storage_path }
+ storage_paths = {"default" => args.storage_path}
Gitlab::SetupHelper.create_gitaly_configuration(args.dir, storage_paths)
Dir.chdir(args.dir) do
# In CI we run scripts/gitaly-test-build instead of this command
- unless ENV['CI'].present?
+ unless ENV["CI"].present?
Bundler.with_original_env { run_command!(command) }
end
end
diff --git a/lib/tasks/gitlab/helpers.rake b/lib/tasks/gitlab/helpers.rake
index 14d1125a03d..5ca40df05cb 100644
--- a/lib/tasks/gitlab/helpers.rake
+++ b/lib/tasks/gitlab/helpers.rake
@@ -1,5 +1,5 @@
# Prevent StateMachine warnings from outputting during a cron task
-StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON']
+StateMachines::Machine.ignore_method_conflicts = true if ENV["CRON"]
task gitlab_environment: :environment do
extend SystemCheck::Helpers
diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake
index adfcc3cda22..a224515b63e 100644
--- a/lib/tasks/gitlab/import.rake
+++ b/lib/tasks/gitlab/import.rake
@@ -11,7 +11,7 @@ namespace :gitlab do
desc "GitLab | Import bare repositories from repositories -> storages into GitLab project instance"
task :repos, [:import_path] => :environment do |_t, args|
unless args.import_path
- puts 'Please specify an import path that contains the repositories'.color(:red)
+ puts "Please specify an import path that contains the repositories".color(:red)
exit 1
end
diff --git a/lib/tasks/gitlab/import_export.rake b/lib/tasks/gitlab/import_export.rake
index 900dbf7be24..f34c83aba7b 100644
--- a/lib/tasks/gitlab/import_export.rake
+++ b/lib/tasks/gitlab/import_export.rake
@@ -7,20 +7,20 @@ namespace :gitlab do
desc "GitLab | Display exported DB structure"
task data: :environment do
- puts YAML.load_file(Gitlab::ImportExport.config_file)['project_tree'].to_yaml(SortKeys: true)
+ puts YAML.load_file(Gitlab::ImportExport.config_file)["project_tree"].to_yaml(SortKeys: true)
end
- desc 'GitLab | Bumps the Import/Export version in fixtures and project templates'
+ desc "GitLab | Bumps the Import/Export version in fixtures and project templates"
task bump_version: :environment do
- archives = Dir['vendor/project_templates/*.tar.gz']
- archives.push('spec/features/projects/import_export/test_project_export.tar.gz')
+ archives = Dir["vendor/project_templates/*.tar.gz"]
+ archives.push("spec/features/projects/import_export/test_project_export.tar.gz")
archives.each do |archive|
raise ArgumentError unless File.exist?(archive)
Dir.mktmpdir do |tmp_dir|
system("tar -zxf #{archive} -C #{tmp_dir} > /dev/null")
- File.write(File.join(tmp_dir, 'VERSION'), Gitlab::ImportExport.version, mode: 'w')
+ File.write(File.join(tmp_dir, "VERSION"), Gitlab::ImportExport.version, mode: "w")
system("tar -zcvf #{archive} -C #{tmp_dir} . > /dev/null")
end
end
diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake
index b8798fb3cfd..d3075d8282b 100644
--- a/lib/tasks/gitlab/info.rake
+++ b/lib/tasks/gitlab/info.rake
@@ -3,26 +3,26 @@ namespace :gitlab do
desc "GitLab | Show information about GitLab and its environment"
task info: :gitlab_environment do
# check if there is an RVM environment
- rvm_version = run_and_match(%w(rvm --version), /[\d\.]+/).try(:to_s)
+ rvm_version = run_and_match(%w[rvm --version], /[\d\.]+/).try(:to_s)
# check Ruby version
- ruby_version = run_and_match(%w(ruby --version), /[\d\.p]+/).try(:to_s)
+ ruby_version = run_and_match(%w[ruby --version], /[\d\.p]+/).try(:to_s)
# check Gem version
- gem_version = run_command(%w(gem --version))
+ gem_version = run_command(%w[gem --version])
# check Bundler version
- bunder_version = run_and_match(%w(bundle --version), /[\d\.]+/).try(:to_s)
+ bunder_version = run_and_match(%w[bundle --version], /[\d\.]+/).try(:to_s)
# check Rake version
- rake_version = run_and_match(%w(rake --version), /[\d\.]+/).try(:to_s)
+ rake_version = run_and_match(%w[rake --version], /[\d\.]+/).try(:to_s)
# check redis version
- redis_version = run_and_match(%w(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a
+ redis_version = run_and_match(%w[redis-cli --version], /redis-cli (\d+\.\d+\.\d+)/).to_a
# check Git version
- git_version = run_and_match([Gitlab.config.git.bin_path, '--version'], /git version ([\d\.]+)/).to_a
+ git_version = run_and_match([Gitlab.config.git.bin_path, "--version"], /git version ([\d\.]+)/).to_a
# check Go version
- go_version = run_and_match(%w(go version), /go version (.+)/).to_a
+ go_version = run_and_match(%w[go version], /go version (.+)/).to_a
puts ""
puts "System information".color(:yellow)
puts "System:\t\t#{os_name || "unknown".color(:red)}"
- puts "Current User:\t#{run_command(%w(whoami))}"
+ puts "Current User:\t#{run_command(%w[whoami])}"
puts "Using RVM:\t#{rvm_version.present? ? "yes".color(:green) : "no"}"
puts "RVM Version:\t#{rvm_version}" if rvm_version.present?
puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}"
@@ -42,7 +42,7 @@ namespace :gitlab do
http_clone_url = project.http_url_to_repo
ssh_clone_url = project.ssh_url_to_repo
- omniauth_providers = Gitlab.config.omniauth.providers.map { |provider| provider['name'] }
+ omniauth_providers = Gitlab.config.omniauth.providers.map { |provider| provider["name"] }
puts ""
puts "GitLab information".color(:yellow)
@@ -55,7 +55,7 @@ namespace :gitlab do
puts "SSH Clone URL:\t#{ssh_clone_url}"
puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".color(:green) : "no"}"
puts "Using Omniauth:\t#{Gitlab::Auth.omniauth_enabled? ? "yes".color(:green) : "no"}"
- puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab::Auth.omniauth_enabled?
+ puts "Omniauth Providers: #{omniauth_providers.join(", ")}" if Gitlab::Auth.omniauth_enabled?
# check Gitolite version
gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.path}/VERSION"
diff --git a/lib/tasks/gitlab/ldap.rake b/lib/tasks/gitlab/ldap.rake
index 0459de27c96..3a17961afe3 100644
--- a/lib/tasks/gitlab/ldap.rake
+++ b/lib/tasks/gitlab/ldap.rake
@@ -1,38 +1,38 @@
namespace :gitlab do
namespace :ldap do
- desc 'GitLab | LDAP | Rename provider'
+ desc "GitLab | LDAP | Rename provider"
task :rename_provider, [:old_provider, :new_provider] => :gitlab_environment do |_, args|
old_provider = args[:old_provider] ||
- prompt('What is the old provider? Ex. \'ldapmain\': '.color(:blue))
+ prompt("What is the old provider? Ex. 'ldapmain': ".color(:blue))
new_provider = args[:new_provider] ||
- prompt('What is the new provider ID? Ex. \'ldapcustom\': '.color(:blue))
- puts '' # Add some separation in the output
+ prompt("What is the new provider ID? Ex. 'ldapcustom': ".color(:blue))
+ puts "" # Add some separation in the output
identities = Identity.where(provider: old_provider)
identity_count = identities.count
if identities.empty?
puts "Found no user identities with '#{old_provider}' provider."
- puts 'Please check the provider name and try again.'
+ puts "Please check the provider name and try again."
exit 1
end
- plural_id_count = ActionController::Base.helpers.pluralize(identity_count, 'user')
+ plural_id_count = ActionController::Base.helpers.pluralize(identity_count, "user")
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts "#{plural_id_count} with provider '#{old_provider}' will be updated to '#{new_provider}'"
- puts 'If the new provider is incorrect, users will be unable to sign in'
+ puts "If the new provider is incorrect, users will be unable to sign in"
ask_to_continue
- puts ''
+ puts ""
end
updated_count = identities.update_all(provider: new_provider)
if updated_count == identity_count
- puts 'User identities were successfully updated'.color(:green)
+ puts "User identities were successfully updated".color(:green)
else
- plural_updated_count = ActionController::Base.helpers.pluralize(updated_count, 'user')
- puts 'Some user identities could not be updated'.color(:red)
+ plural_updated_count = ActionController::Base.helpers.pluralize(updated_count, "user")
+ puts "Some user identities could not be updated".color(:red)
puts "Successfully updated #{plural_updated_count} out of #{plural_id_count} total"
end
end
diff --git a/lib/tasks/gitlab/lfs/check.rake b/lib/tasks/gitlab/lfs/check.rake
index 869463d4e5d..dbcb9697643 100644
--- a/lib/tasks/gitlab/lfs/check.rake
+++ b/lib/tasks/gitlab/lfs/check.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :lfs do
- desc 'GitLab | LFS | Check integrity of uploaded LFS objects'
+ desc "GitLab | LFS | Check integrity of uploaded LFS objects"
task check: :environment do
Gitlab::Verify::RakeTask.run!(Gitlab::Verify::LfsObjects)
end
diff --git a/lib/tasks/gitlab/lfs/migrate.rake b/lib/tasks/gitlab/lfs/migrate.rake
index a45e5ca91e0..7560e1022ce 100644
--- a/lib/tasks/gitlab/lfs/migrate.rake
+++ b/lib/tasks/gitlab/lfs/migrate.rake
@@ -1,21 +1,20 @@
-require 'logger'
+require "logger"
desc "GitLab | Migrate LFS objects to remote storage"
namespace :gitlab do
namespace :lfs do
task migrate: :environment do
logger = Logger.new(STDOUT)
- logger.info('Starting transfer of LFS files to object storage')
+ logger.info("Starting transfer of LFS files to object storage")
LfsObject.with_files_stored_locally
.find_each(batch_size: 10) do |lfs_object|
- begin
- lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
- logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
- rescue => e
- logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
- end
+ lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
+
+ logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
+ rescue => e
+ logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
end
end
end
diff --git a/lib/tasks/gitlab/list_repos.rake b/lib/tasks/gitlab/list_repos.rake
index b854c34a8e5..43dc65adf89 100644
--- a/lib/tasks/gitlab/list_repos.rake
+++ b/lib/tasks/gitlab/list_repos.rake
@@ -1,12 +1,12 @@
namespace :gitlab do
task list_repos: :environment do
scope = Project
- if ENV['SINCE']
- date = Time.parse(ENV['SINCE'])
+ if ENV["SINCE"]
+ date = Time.parse(ENV["SINCE"])
warn "Listing repositories with activity or changes since #{date}"
- project_ids = Project.where('last_activity_at > ? OR updated_at > ?', date, date).pluck(:id).sort
- namespace_ids = Namespace.where(['updated_at > ?', date]).pluck(:id).sort
- scope = scope.where('id IN (?) OR namespace_id in (?)', project_ids, namespace_ids)
+ project_ids = Project.where("last_activity_at > ? OR updated_at > ?", date, date).pluck(:id).sort
+ namespace_ids = Namespace.where(["updated_at > ?", date]).pluck(:id).sort
+ scope = scope.where("id IN (?) OR namespace_id in (?)", project_ids, namespace_ids)
end
scope.find_each do |project|
diff --git a/lib/tasks/gitlab/pages.rake b/lib/tasks/gitlab/pages.rake
index 100e480bd66..1f536d8c6e8 100644
--- a/lib/tasks/gitlab/pages.rake
+++ b/lib/tasks/gitlab/pages.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :pages do
- desc 'Ping the pages admin API'
+ desc "Ping the pages admin API"
task admin_ping: :gitlab_environment do
Gitlab::PagesClient.ping
puts "OK: gitlab-pages admin API is reachable"
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake
index e876b23d43f..ec4d3c06f77 100644
--- a/lib/tasks/gitlab/setup.rake
+++ b/lib/tasks/gitlab/setup.rake
@@ -18,7 +18,7 @@ namespace :gitlab do
def setup_db
warn_user_is_not_gitlab
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts "This will create the necessary database tables and seed the database."
puts "You will lose any previous data stored in the database."
ask_to_continue
@@ -49,10 +49,10 @@ namespace :gitlab do
return false unless Gitlab::Database.postgresql?
cmd = <<~SQL
- SELECT pg_terminate_backend(pg_stat_activity.pid)
- FROM pg_stat_activity
- WHERE datname = current_database()
- AND pid <> pg_backend_pid();
+ SELECT pg_terminate_backend(pg_stat_activity.pid)
+ FROM pg_stat_activity
+ WHERE datname = current_database()
+ AND pid <> pg_backend_pid();
SQL
ActiveRecord::Base.connection.execute(cmd)&.result_status == PG::PGRES_TUPLES_OK
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index 0ebc6f00793..75604da22ad 100644
--- a/lib/tasks/gitlab/shell.rake
+++ b/lib/tasks/gitlab/shell.rake
@@ -5,11 +5,11 @@ namespace :gitlab do
warn_user_is_not_gitlab
default_version = Gitlab::Shell.version_required
- args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitlab-shell.git')
+ args.with_defaults(repo: "https://gitlab.com/gitlab-org/gitlab-shell.git")
gitlab_url = Gitlab.config.gitlab.url
# gitlab-shell requires a / at the end of the url
- gitlab_url += '/' unless gitlab_url.end_with?('/')
+ gitlab_url += "/" unless gitlab_url.end_with?("/")
target_dir = Gitlab.config.gitlab_shell.path
checkout_or_clone_version(version: default_version, repo: args.repo, target_dir: target_dir)
@@ -19,40 +19,40 @@ namespace :gitlab do
config = {
user: Gitlab.config.gitlab.user,
gitlab_url: gitlab_url,
- http_settings: { self_signed_cert: false }.stringify_keys,
+ http_settings: {self_signed_cert: false}.stringify_keys,
auth_file: File.join(user_home, ".ssh", "authorized_keys"),
redis: {
bin: `which redis-cli`.chomp,
- namespace: "resque:gitlab"
+ namespace: "resque:gitlab",
}.stringify_keys,
log_level: "INFO",
- audit_usernames: false
+ audit_usernames: false,
}.stringify_keys
- redis_url = URI.parse(ENV['REDIS_URL'] || "redis://localhost:6379")
+ redis_url = URI.parse(ENV["REDIS_URL"] || "redis://localhost:6379")
- if redis_url.scheme == 'unix'
- config['redis']['socket'] = redis_url.path
+ if redis_url.scheme == "unix"
+ config["redis"]["socket"] = redis_url.path
else
- config['redis']['host'] = redis_url.host
- config['redis']['port'] = redis_url.port
+ config["redis"]["host"] = redis_url.host
+ config["redis"]["port"] = redis_url.port
end
# Generate config.yml based on existing gitlab settings
File.open("config.yml", "w+") {|f| f.puts config.to_yaml}
[
- %w(bin/install) + repository_storage_paths_args,
- %w(bin/compile)
+ %w[bin/install] + repository_storage_paths_args,
+ %w[bin/compile],
].each do |cmd|
unless Kernel.system(*cmd)
- raise "command failed: #{cmd.join(' ')}"
+ raise "command failed: #{cmd.join(" ")}"
end
end
end
# (Re)create hooks
- Rake::Task['gitlab:shell:create_hooks'].invoke
+ Rake::Task["gitlab:shell:create_hooks"].invoke
Gitlab::Shell.ensure_secret_token!
end
@@ -67,25 +67,25 @@ namespace :gitlab do
Project.find_each(batch_size: 1000) do |project|
path_to_repo = project.repository.path_to_repo
if File.exist?(path_to_repo)
- print '-'
+ print "-"
else
if Gitlab::Shell.new.create_repository(project.repository_storage,
- project.disk_path)
- print '.'
+ project.disk_path)
+ print "."
else
- print 'F'
+ print "F"
end
end
end
end
- desc 'Create or repair repository hooks symlink'
+ desc "Create or repair repository hooks symlink"
task create_hooks: :gitlab_environment do
warn_user_is_not_gitlab
- puts 'Creating/Repairing hooks symlinks for all repositories'
- system(*%W(#{Gitlab.config.gitlab_shell.path}/bin/create-hooks) + repository_storage_paths_args)
- puts 'done'.color(:green)
+ puts "Creating/Repairing hooks symlinks for all repositories"
+ system(*%W[#{Gitlab.config.gitlab_shell.path}/bin/create-hooks] + repository_storage_paths_args)
+ puts "done".color(:green)
end
end
@@ -94,7 +94,7 @@ namespace :gitlab do
ensure_write_to_authorized_keys_is_enabled
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts "This task will now rebuild the authorized_keys file."
puts "You will lose any data stored in the authorized_keys file."
ask_to_continue
@@ -106,7 +106,7 @@ namespace :gitlab do
Gitlab::Shell.new.batch_add_keys do |adder|
Key.find_each(batch_size: 1000) do |key|
adder.add_key(key.shell_id, key.key)
- print '.'
+ print "."
end
end
puts ""
@@ -115,7 +115,6 @@ namespace :gitlab do
puts "Failed to add keys...".color(:red)
exit 1
end
-
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".color(:red)
exit 1
@@ -126,7 +125,7 @@ namespace :gitlab do
puts authorized_keys_is_disabled_warning
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts 'Do you want to permanently enable the "Write to authorized_keys file" setting now?'
ask_to_continue
end
@@ -135,7 +134,7 @@ namespace :gitlab do
Gitlab::CurrentSettings.current_application_settings.update!(authorized_keys_enabled: true)
puts 'Successfully enabled "Write to authorized_keys file"!'
- puts ''
+ puts ""
end
def authorized_keys_is_disabled_warning
diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake
index f9ce3e1d338..ad9ef0b2e61 100644
--- a/lib/tasks/gitlab/storage.rake
+++ b/lib/tasks/gitlab/storage.rake
@@ -1,9 +1,9 @@
namespace :gitlab do
namespace :storage do
- desc 'GitLab | Storage | Migrate existing projects to Hashed Storage'
+ desc "GitLab | Storage | Migrate existing projects to Hashed Storage"
task migrate_to_hashed: :environment do
if Gitlab::Database.read_only?
- warn 'This task requires database write access. Exiting.'
+ warn "This task requires database write access. Exiting."
next
end
@@ -29,7 +29,7 @@ namespace :gitlab do
legacy_projects_count = Project.with_unmigrated_storage.count
if legacy_projects_count == 0
- warn 'There are no projects requiring storage migration. Nothing to do!'
+ warn "There are no projects requiring storage migration. Nothing to do!"
next
end
@@ -39,58 +39,58 @@ namespace :gitlab do
helper.project_id_batches do |start, finish|
storage_migrator.bulk_schedule(start: start, finish: finish)
- print '.'
+ print "."
end
- puts ' Done!'
+ puts " Done!"
end
- desc 'Gitlab | Storage | Summary of existing projects using Legacy Storage'
+ desc "Gitlab | Storage | Summary of existing projects using Legacy Storage"
task legacy_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('projects using Legacy Storage', Project.without_storage_feature(:repository))
+ helper.relation_summary("projects using Legacy Storage", Project.without_storage_feature(:repository))
end
- desc 'Gitlab | Storage | List existing projects using Legacy Storage'
+ desc "Gitlab | Storage | List existing projects using Legacy Storage"
task list_legacy_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.projects_list('projects using Legacy Storage', Project.without_storage_feature(:repository))
+ helper.projects_list("projects using Legacy Storage", Project.without_storage_feature(:repository))
end
- desc 'Gitlab | Storage | Summary of existing projects using Hashed Storage'
+ desc "Gitlab | Storage | Summary of existing projects using Hashed Storage"
task hashed_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('projects using Hashed Storage', Project.with_storage_feature(:repository))
+ helper.relation_summary("projects using Hashed Storage", Project.with_storage_feature(:repository))
end
- desc 'Gitlab | Storage | List existing projects using Hashed Storage'
+ desc "Gitlab | Storage | List existing projects using Hashed Storage"
task list_hashed_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.projects_list('projects using Hashed Storage', Project.with_storage_feature(:repository))
+ helper.projects_list("projects using Hashed Storage", Project.with_storage_feature(:repository))
end
- desc 'Gitlab | Storage | Summary of project attachments using Legacy Storage'
+ desc "Gitlab | Storage | Summary of project attachments using Legacy Storage"
task legacy_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('attachments using Legacy Storage', helper.legacy_attachments_relation)
+ helper.relation_summary("attachments using Legacy Storage", helper.legacy_attachments_relation)
end
- desc 'Gitlab | Storage | List existing project attachments using Legacy Storage'
+ desc "Gitlab | Storage | List existing project attachments using Legacy Storage"
task list_legacy_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.attachments_list('attachments using Legacy Storage', helper.legacy_attachments_relation)
+ helper.attachments_list("attachments using Legacy Storage", helper.legacy_attachments_relation)
end
- desc 'Gitlab | Storage | Summary of project attachments using Hashed Storage'
+ desc "Gitlab | Storage | Summary of project attachments using Hashed Storage"
task hashed_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('attachments using Hashed Storage', helper.hashed_attachments_relation)
+ helper.relation_summary("attachments using Hashed Storage", helper.hashed_attachments_relation)
end
- desc 'Gitlab | Storage | List existing project attachments using Hashed Storage'
+ desc "Gitlab | Storage | List existing project attachments using Hashed Storage"
task list_hashed_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.attachments_list('attachments using Hashed Storage', helper.hashed_attachments_relation)
+ helper.attachments_list("attachments using Hashed Storage", helper.hashed_attachments_relation)
end
end
end
diff --git a/lib/tasks/gitlab/tcp_check.rake b/lib/tasks/gitlab/tcp_check.rake
index 1400f57d6b9..6a44862a9ff 100644
--- a/lib/tasks/gitlab/tcp_check.rake
+++ b/lib/tasks/gitlab/tcp_check.rake
@@ -13,7 +13,7 @@ namespace :gitlab do
else
puts "TCP connection to #{checker.remote} failed: #{checker.error}".color(:red)
puts
- puts 'Check that host and port are correct, and that the traffic is permitted through any firewalls.'
+ puts "Check that host and port are correct, and that the traffic is permitted through any firewalls."
exit 1
end
end
diff --git a/lib/tasks/gitlab/test.rake b/lib/tasks/gitlab/test.rake
index 2222807fe13..7a64baf7f8d 100644
--- a/lib/tasks/gitlab/test.rake
+++ b/lib/tasks/gitlab/test.rake
@@ -2,14 +2,14 @@ namespace :gitlab do
desc "GitLab | Run all tests"
task :test do
cmds = [
- %w(rake brakeman),
- %w(rake rubocop),
- %w(rake spec),
- %w(rake karma)
+ %w[rake brakeman],
+ %w[rake rubocop],
+ %w[rake spec],
+ %w[rake karma],
]
cmds.each do |cmd|
- system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
+ system({"RAILS_ENV" => "test", "force" => "yes"}, *cmd) || raise("#{cmd} failed!")
end
end
end
diff --git a/lib/tasks/gitlab/traces.rake b/lib/tasks/gitlab/traces.rake
index 5a232091a7e..8e060a77cbd 100644
--- a/lib/tasks/gitlab/traces.rake
+++ b/lib/tasks/gitlab/traces.rake
@@ -1,12 +1,12 @@
-require 'logger'
-require 'resolv-replace'
+require "logger"
+require "resolv-replace"
desc "GitLab | Archive legacy traces to trace artifacts"
namespace :gitlab do
namespace :traces do
task archive: :environment do
logger = Logger.new(STDOUT)
- logger.info('Archiving legacy traces')
+ logger.info("Archiving legacy traces")
Ci::Build.finished.without_archived_trace
.order(id: :asc)
@@ -21,18 +21,17 @@ namespace :gitlab do
task migrate: :environment do
logger = Logger.new(STDOUT)
- logger.info('Starting transfer of job traces')
+ logger.info("Starting transfer of job traces")
Ci::Build.joins(:project)
.with_archived_trace_stored_locally
.find_each(batch_size: 10) do |build|
- begin
- build.job_artifacts_trace.file.migrate!(ObjectStorage::Store::REMOTE)
- logger.info("Transferred job trace of #{build.id} to object storage")
- rescue => e
- logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
- end
+ build.job_artifacts_trace.file.migrate!(ObjectStorage::Store::REMOTE)
+
+ logger.info("Transferred job trace of #{build.id} to object storage")
+ rescue => e
+ logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
end
end
end
diff --git a/lib/tasks/gitlab/track_deployment.rake b/lib/tasks/gitlab/track_deployment.rake
index 6f101aea303..8814a53fd90 100644
--- a/lib/tasks/gitlab/track_deployment.rake
+++ b/lib/tasks/gitlab/track_deployment.rake
@@ -1,8 +1,8 @@
namespace :gitlab do
- desc 'GitLab | Tracks a deployment in GitLab Performance Monitoring'
+ desc "GitLab | Tracks a deployment in GitLab Performance Monitoring"
task track_deployment: :environment do
metric = Gitlab::Metrics::Metric
- .new('deployments', version: Gitlab::VERSION)
+ .new("deployments", version: Gitlab::VERSION)
Gitlab::Metrics.submit_metrics([metric.to_hash])
end
diff --git a/lib/tasks/gitlab/two_factor.rake b/lib/tasks/gitlab/two_factor.rake
index 6b22499a5c8..d2400181dfd 100644
--- a/lib/tasks/gitlab/two_factor.rake
+++ b/lib/tasks/gitlab/two_factor.rake
@@ -22,12 +22,12 @@ namespace :gitlab do
namespace :rotate_key do
def rotator
- @rotator ||= Gitlab::OtpKeyRotator.new(ENV['filename'])
+ @rotator ||= Gitlab::OtpKeyRotator.new(ENV["filename"])
end
desc "Encrypt user OTP secrets with a new encryption key"
task apply: :environment do |t, args|
- rotator.rotate!(old_key: ENV['old_key'], new_key: ENV['new_key'])
+ rotator.rotate!(old_key: ENV["old_key"], new_key: ENV["new_key"])
end
desc "Rollback to secrets encrypted with the old encryption key"
diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake
index abe10f5580e..eef13a9d90e 100644
--- a/lib/tasks/gitlab/update_templates.rake
+++ b/lib/tasks/gitlab/update_templates.rake
@@ -25,7 +25,7 @@ namespace :gitlab do
import_url: template.clone_url,
namespace_id: admin.namespace.id,
path: template.name,
- skip_wiki: true
+ skip_wiki: true,
}
puts "Creating project for #{template.title}"
@@ -102,10 +102,10 @@ namespace :gitlab do
Template.new(
"https://gitlab.com/gitlab-org/Dockerfile.git",
/(\.{1,2}|LICENSE|CONTRIBUTING.md|\.Dockerfile)\z/
- )
+ ),
].freeze
def vendor_directory
- Rails.root.join('vendor')
+ Rails.root.join("vendor")
end
end
diff --git a/lib/tasks/gitlab/uploads/check.rake b/lib/tasks/gitlab/uploads/check.rake
index 2be2ec7f9c9..d7d55bef28d 100644
--- a/lib/tasks/gitlab/uploads/check.rake
+++ b/lib/tasks/gitlab/uploads/check.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :uploads do
- desc 'GitLab | Uploads | Check integrity of uploaded files'
+ desc "GitLab | Uploads | Check integrity of uploaded files"
task check: :environment do
Gitlab::Verify::RakeTask.run!(Gitlab::Verify::Uploads)
end
diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake
index 1c93609a006..c2ab52b9907 100644
--- a/lib/tasks/gitlab/uploads/migrate.rake
+++ b/lib/tasks/gitlab/uploads/migrate.rake
@@ -3,17 +3,17 @@ namespace :gitlab do
namespace :migrate do
desc "GitLab | Uploads | Migrate all uploaded files to object storage"
task all: :environment do
- categories = [%w(AvatarUploader Project :avatar),
- %w(AvatarUploader Group :avatar),
- %w(AvatarUploader User :avatar),
- %w(AttachmentUploader Note :attachment),
- %w(AttachmentUploader Appearance :logo),
- %w(AttachmentUploader Appearance :header_logo),
- %w(FaviconUploader Appearance :favicon),
- %w(FileUploader Project),
- %w(PersonalFileUploader Snippet),
- %w(NamespaceFileUploader Snippet),
- %w(FileUploader MergeRequest)]
+ categories = [%w[AvatarUploader Project :avatar],
+ %w[AvatarUploader Group :avatar],
+ %w[AvatarUploader User :avatar],
+ %w[AttachmentUploader Note :attachment],
+ %w[AttachmentUploader Appearance :logo],
+ %w[AttachmentUploader Appearance :header_logo],
+ %w[FaviconUploader Appearance :favicon],
+ %w[FileUploader Project],
+ %w[PersonalFileUploader Snippet],
+ %w[NamespaceFileUploader Snippet],
+ %w[FileUploader MergeRequest],]
categories.each do |args|
Rake::Task["gitlab:uploads:migrate"].invoke(*args)
@@ -24,11 +24,11 @@ namespace :gitlab do
# The following is the actual rake task that migrates uploads of specified
# category to object storage
- desc 'GitLab | Uploads | Migrate the uploaded files of specified type to object storage'
+ desc "GitLab | Uploads | Migrate the uploaded files of specified type to object storage"
task :migrate, [:uploader_class, :model_class, :mounted_as] => :environment do |task, args|
- batch_size = ENV.fetch('BATCH', 200).to_i
+ batch_size = ENV.fetch("BATCH", 200).to_i
@to_store = ObjectStorage::Store::REMOTE
- @mounted_as = args.mounted_as&.gsub(':', '')&.to_sym
+ @mounted_as = args.mounted_as&.gsub(":", "")&.to_sym
@uploader_class = args.uploader_class.constantize
@model_class = args.model_class.constantize
@@ -37,9 +37,9 @@ namespace :gitlab do
def enqueue_batch(batch, index)
job = ObjectStorage::MigrateUploadsWorker.enqueue!(batch,
- @model_class,
- @mounted_as,
- @to_store)
+ @model_class,
+ @mounted_as,
+ @to_store)
puts "Enqueued job ##{index}: #{job}"
rescue ObjectStorage::MigrateUploadsWorker::SanityCheckError => e
# continue for the next batch
diff --git a/lib/tasks/gitlab/web_hook.rake b/lib/tasks/gitlab/web_hook.rake
index 15cec80b6a6..92038fa3228 100644
--- a/lib/tasks/gitlab/web_hook.rake
+++ b/lib/tasks/gitlab/web_hook.rake
@@ -2,8 +2,8 @@ namespace :gitlab do
namespace :web_hook do
desc "GitLab | Adds a webhook to the projects"
task add: :environment do
- web_hook_url = ENV['URL']
- namespace_path = ENV['NAMESPACE']
+ web_hook_url = ENV["URL"]
+ namespace_path = ENV["NAMESPACE"]
projects = find_projects(namespace_path)
@@ -22,8 +22,8 @@ namespace :gitlab do
desc "GitLab | Remove a webhook from the projects"
task rm: :environment do
- web_hook_url = ENV['URL']
- namespace_path = ENV['NAMESPACE']
+ web_hook_url = ENV["URL"]
+ namespace_path = ENV["NAMESPACE"]
web_hooks = find_web_hooks(namespace_path)
@@ -46,7 +46,7 @@ namespace :gitlab do
desc "GitLab | List webhooks"
task list: :environment do
- namespace_path = ENV['NAMESPACE']
+ namespace_path = ENV["NAMESPACE"]
web_hooks = find_web_hooks(namespace_path)
web_hooks.find_each do |hook|
diff --git a/lib/tasks/gitlab/workhorse.rake b/lib/tasks/gitlab/workhorse.rake
index b917a293095..be1d278f63b 100644
--- a/lib/tasks/gitlab/workhorse.rake
+++ b/lib/tasks/gitlab/workhorse.rake
@@ -8,14 +8,14 @@ namespace :gitlab do
abort %(Please specify the directory where you want to install gitlab-workhorse:\n rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]")
end
- args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitlab-workhorse.git')
+ args.with_defaults(repo: "https://gitlab.com/gitlab-org/gitlab-workhorse.git")
version = Gitlab::Workhorse.version
checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir)
_, status = Gitlab::Popen.popen(%w[which gmake])
- command = status.zero? ? 'gmake' : 'make'
+ command = status.zero? ? "gmake" : "make"
Dir.chdir(args.dir) do
run_command!([command])
diff --git a/lib/tasks/grape.rake b/lib/tasks/grape.rake
index ea2698da606..b0739faa9c4 100644
--- a/lib/tasks/grape.rake
+++ b/lib/tasks/grape.rake
@@ -1,5 +1,5 @@
namespace :grape do
- desc 'Print compiled grape routes'
+ desc "Print compiled grape routes"
task routes: :environment do
API::API.routes.each do |route|
puts "#{route.options[:method]} #{route.path} - #{route_description(route.options)}"
diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake
index 786efd14b1a..63344f448cb 100644
--- a/lib/tasks/haml-lint.rake
+++ b/lib/tasks/haml-lint.rake
@@ -1,13 +1,13 @@
unless Rails.env.production?
- require 'haml_lint/rake_task'
- require 'haml_lint/inline_javascript'
+ require "haml_lint/rake_task"
+ require "haml_lint/inline_javascript"
# Workaround for warnings from parser/current
# Keep it even if it no longer emits any warnings,
# because we'll still see warnings in console/server anyway,
# and we don't need to break static-analysis for this.
task :haml_lint do
- require 'parser'
+ require "parser"
def Parser.warn(*args)
puts(*args) # static-analysis ignores stdout if status is 0
end
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index f912f521dfb..6bd83ef1b2b 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -1,5 +1,5 @@
-require 'benchmark'
-require 'rainbow/ext/string'
+require "benchmark"
+require "rainbow/ext/string"
class GithubImport
def self.run!(*args)
@@ -7,7 +7,7 @@ class GithubImport
end
def initialize(token, gitlab_username, project_path, extras)
- @options = { token: token }
+ @options = {token: token}
@project_path = project_path
@current_user = UserFinder.new(gitlab_username).find_by_username
@@ -21,7 +21,7 @@ class GithubImport
.new(@options[:token], @current_user, @github_repo)
.choose_one!
- raise 'No repo found!' unless @repo
+ raise "No repo found!" unless @repo
show_warning!
@@ -38,7 +38,7 @@ class GithubImport
STDIN.getch
- puts 'Starting the import (this could take a while)'.color(:green)
+ puts "Starting the import (this could take a while)".color(:green)
end
def import!
@@ -46,11 +46,11 @@ class GithubImport
import_success = false
- timings = Benchmark.measure do
+ timings = Benchmark.measure {
import_success = Gitlab::GithubImport::SequentialImporter
.new(@project, token: @options[:token])
.execute
- end
+ }
if import_success
@project.after_import
@@ -63,7 +63,7 @@ class GithubImport
def new_project
Project.transaction do
- namespace_path, _sep, name = @project_path.rpartition('/')
+ namespace_path, _sep, name = @project_path.rpartition("/")
namespace = find_or_create_namespace(namespace_path)
project = Projects::CreateService.new(
@@ -77,9 +77,9 @@ class GithubImport
).execute
project.update!(
- import_type: 'github',
+ import_type: "github",
import_source: @repo.full_name,
- import_url: @repo.clone_url.sub('://', "://#{@options[:token]}@")
+ import_url: @repo.clone_url.sub("://", "://#{@options[:token]}@")
)
project
@@ -119,7 +119,7 @@ class GithubRepos
print "\tName: #{repo.full_name}\n".color(:green)
end
- print 'ID? '.bright
+ print "ID? ".bright
repos.find { |repo| repo.id == repo_id }
end
@@ -138,9 +138,9 @@ class GithubRepos
end
namespace :import do
- desc 'Import a GitHub project - Example: import:github[ToKeN,root,root/blah,my/github_repo] (optional my/github_repo)'
+ desc "Import a GitHub project - Example: import:github[ToKeN,root,root/blah,my/github_repo] (optional my/github_repo)"
task :github, [:token, :gitlab_username, :project_path] => :environment do |_t, args|
- abort 'Project path must be: namespace(s)/project_name'.color(:red) unless args.project_path.include?('/')
+ abort "Project path must be: namespace(s)/project_name".color(:red) unless args.project_path.include?("/")
GithubImport.run!(args.token, args.gitlab_username, args.project_path, args.extras)
end
diff --git a/lib/tasks/karma.rake b/lib/tasks/karma.rake
index 62a12174efa..3a00073d509 100644
--- a/lib/tasks/karma.rake
+++ b/lib/tasks/karma.rake
@@ -1,21 +1,21 @@
unless Rails.env.production?
namespace :karma do
- desc 'GitLab | Karma | Generate fixtures for JavaScript tests'
+ desc "GitLab | Karma | Generate fixtures for JavaScript tests"
RSpec::Core::RakeTask.new(:fixtures, [:pattern]) do |t, args|
- args.with_defaults(pattern: 'spec/javascripts/fixtures/*.rb')
- ENV['NO_KNAPSACK'] = 'true'
+ args.with_defaults(pattern: "spec/javascripts/fixtures/*.rb")
+ ENV["NO_KNAPSACK"] = "true"
t.pattern = args[:pattern]
- t.rspec_opts = '--format documentation'
+ t.rspec_opts = "--format documentation"
end
- desc 'GitLab | Karma | Run JavaScript tests'
- task tests: ['yarn:check'] do
+ desc "GitLab | Karma | Run JavaScript tests"
+ task tests: ["yarn:check"] do
sh "yarn run karma" do |ok, res|
- abort('rake karma:tests failed') unless ok
+ abort("rake karma:tests failed") unless ok
end
end
end
- desc 'GitLab | Karma | Shortcut for karma:fixtures and karma:tests'
- task karma: ['karma:fixtures', 'karma:tests']
+ desc "GitLab | Karma | Shortcut for karma:fixtures and karma:tests"
+ task karma: ["karma:fixtures", "karma:tests"]
end
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index 5d673a1a285..6680bf0fb4a 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -1,7 +1,7 @@
unless Rails.env.production?
namespace :lint do
task :static_verification_env do
- ENV['STATIC_VERIFICATION'] = 'true'
+ ENV["STATIC_VERIFICATION"] = "true"
end
desc "GitLab | lint | Static verification"
@@ -14,16 +14,14 @@ unless Rails.env.production?
desc "GitLab | lint | Lint JavaScript files using ESLint"
task :javascript do
- Rake::Task['eslint'].invoke
+ Rake::Task["eslint"].invoke
end
desc "GitLab | lint | Lint HAML files"
task :haml do
- begin
- Rake::Task['haml_lint'].invoke
- rescue RuntimeError # The haml_lint tasks raise a RuntimeError
- exit(1)
- end
+ Rake::Task["haml_lint"].invoke
+ rescue RuntimeError # The haml_lint tasks raise a RuntimeError
+ exit(1)
end
desc "GitLab | lint | Run several lint checks"
@@ -38,7 +36,7 @@ unless Rails.env.production?
gettext:updated_check
lint:static_verification
].each do |task|
- pid = Process.fork do
+ pid = Process.fork {
rd_out, wr_out = IO.pipe
rd_err, wr_err = IO.pipe
stdout = $stdout.dup
@@ -65,7 +63,7 @@ unless Rails.env.production?
IO.copy_stream(rd_out, $stdout)
IO.copy_stream(rd_err, $stderr)
end
- end
+ }
Process.waitpid(pid)
status += $?.exitstatus
diff --git a/lib/tasks/migrate/add_limits_mysql.rake b/lib/tasks/migrate/add_limits_mysql.rake
index c77fa49d586..81392a3769b 100644
--- a/lib/tasks/migrate/add_limits_mysql.rake
+++ b/lib/tasks/migrate/add_limits_mysql.rake
@@ -1,9 +1,9 @@
-require Rails.root.join('db/migrate/limits_to_mysql')
-require Rails.root.join('db/migrate/markdown_cache_limits_to_mysql')
-require Rails.root.join('db/migrate/merge_request_diff_file_limits_to_mysql')
-require Rails.root.join('db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql')
-require Rails.root.join('db/migrate/gpg_keys_limits_to_mysql')
-require Rails.root.join('db/migrate/prometheus_metrics_limits_to_mysql')
+require Rails.root.join("db/migrate/limits_to_mysql")
+require Rails.root.join("db/migrate/markdown_cache_limits_to_mysql")
+require Rails.root.join("db/migrate/merge_request_diff_file_limits_to_mysql")
+require Rails.root.join("db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql")
+require Rails.root.join("db/migrate/gpg_keys_limits_to_mysql")
+require Rails.root.join("db/migrate/prometheus_metrics_limits_to_mysql")
desc "GitLab | Add limits to strings in mysql database"
task add_limits_mysql: :environment do
diff --git a/lib/tasks/migrate/composite_primary_keys.rake b/lib/tasks/migrate/composite_primary_keys.rake
index eb112434dd9..fb8bba42a84 100644
--- a/lib/tasks/migrate/composite_primary_keys.rake
+++ b/lib/tasks/migrate/composite_primary_keys.rake
@@ -1,14 +1,14 @@
namespace :gitlab do
namespace :db do
- desc 'GitLab | Adds primary keys to tables that only have composite unique keys'
+ desc "GitLab | Adds primary keys to tables that only have composite unique keys"
task composite_primary_keys_add: :environment do
- require Rails.root.join('db/optional_migrations/composite_primary_keys')
+ require Rails.root.join("db/optional_migrations/composite_primary_keys")
CompositePrimaryKeysMigration.new.up
end
- desc 'GitLab | Removes previously added composite primary keys'
+ desc "GitLab | Removes previously added composite primary keys"
task composite_primary_keys_drop: :environment do
- require Rails.root.join('db/optional_migrations/composite_primary_keys')
+ require Rails.root.join("db/optional_migrations/composite_primary_keys")
CompositePrimaryKeysMigration.new.down
end
end
diff --git a/lib/tasks/migrate/migrate_iids.rake b/lib/tasks/migrate/migrate_iids.rake
index aa2d01730d7..b04ab63efa9 100644
--- a/lib/tasks/migrate/migrate_iids.rake
+++ b/lib/tasks/migrate/migrate_iids.rake
@@ -1,51 +1,45 @@
desc "GitLab | Build internal ids for issues and merge requests"
task migrate_iids: :environment do
- puts 'Issues'.color(:yellow)
+ puts "Issues".color(:yellow)
Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
- begin
- issue.set_iid
+ issue.set_iid
- if issue.update_attribute(:iid, issue.iid)
- print '.'
- else
- print 'F'
- end
- rescue
- print 'F'
+ if issue.update_attribute(:iid, issue.iid)
+ print "."
+ else
+ print "F"
end
+ rescue
+ print "F"
end
- puts 'done'
- puts 'Merge Requests'.color(:yellow)
+ puts "done"
+ puts "Merge Requests".color(:yellow)
MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr|
- begin
- mr.set_iid
+ mr.set_iid
- if mr.update_attribute(:iid, mr.iid)
- print '.'
- else
- print 'F'
- end
- rescue
- print 'F'
+ if mr.update_attribute(:iid, mr.iid)
+ print "."
+ else
+ print "F"
end
+ rescue
+ print "F"
end
- puts 'done'
- puts 'Milestones'.color(:yellow)
+ puts "done"
+ puts "Milestones".color(:yellow)
Milestone.where(iid: nil).find_each(batch_size: 100) do |m|
- begin
- m.set_iid
+ m.set_iid
- if m.update_attribute(:iid, m.iid)
- print '.'
- else
- print 'F'
- end
- rescue
- print 'F'
+ if m.update_attribute(:iid, m.iid)
+ print "."
+ else
+ print "F"
end
+ rescue
+ print "F"
end
- puts 'done'
+ puts "done"
end
diff --git a/lib/tasks/migrate/setup_postgresql.rake b/lib/tasks/migrate/setup_postgresql.rake
index f69d204c579..5d1a1433fd8 100644
--- a/lib/tasks/migrate/setup_postgresql.rake
+++ b/lib/tasks/migrate/setup_postgresql.rake
@@ -1,15 +1,15 @@
-desc 'GitLab | Sets up PostgreSQL'
+desc "GitLab | Sets up PostgreSQL"
task setup_postgresql: :environment do
- require Rails.root.join('db/migrate/20151007120511_namespaces_projects_path_lower_indexes')
- require Rails.root.join('db/migrate/20151008110232_add_users_lower_username_email_indexes')
- require Rails.root.join('db/migrate/20161212142807_add_lower_path_index_to_routes')
- require Rails.root.join('db/migrate/20170317203554_index_routes_path_for_like')
- require Rails.root.join('db/migrate/20170724214302_add_lower_path_index_to_redirect_routes')
- require Rails.root.join('db/migrate/20170503185032_index_redirect_routes_path_for_like')
- require Rails.root.join('db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb')
- require Rails.root.join('db/migrate/20180215181245_users_name_lower_index.rb')
- require Rails.root.join('db/migrate/20180504195842_project_name_lower_index.rb')
- require Rails.root.join('db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb')
+ require Rails.root.join("db/migrate/20151007120511_namespaces_projects_path_lower_indexes")
+ require Rails.root.join("db/migrate/20151008110232_add_users_lower_username_email_indexes")
+ require Rails.root.join("db/migrate/20161212142807_add_lower_path_index_to_routes")
+ require Rails.root.join("db/migrate/20170317203554_index_routes_path_for_like")
+ require Rails.root.join("db/migrate/20170724214302_add_lower_path_index_to_redirect_routes")
+ require Rails.root.join("db/migrate/20170503185032_index_redirect_routes_path_for_like")
+ require Rails.root.join("db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb")
+ require Rails.root.join("db/migrate/20180215181245_users_name_lower_index.rb")
+ require Rails.root.join("db/migrate/20180504195842_project_name_lower_index.rb")
+ require Rails.root.join("db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb")
NamespacesProjectsPathLowerIndexes.new.up
AddUsersLowerUsernameEmailIndexes.new.up
@@ -23,17 +23,17 @@ task setup_postgresql: :environment do
AddPathIndexToRedirectRoutes.new.up
end
-desc 'GitLab | Generate PostgreSQL Password Hash'
+desc "GitLab | Generate PostgreSQL Password Hash"
task :postgresql_md5_hash do
- require 'digest'
- username = ENV.fetch('USERNAME') do |missing|
+ require "digest"
+ username = ENV.fetch("USERNAME") { |missing|
puts "You must provide an username with '#{missing}' ENV variable"
exit(1)
- end
- password = ENV.fetch('PASSWORD') do |missing|
+ }
+ password = ENV.fetch("PASSWORD") { |missing|
puts "You must provide a password with '#{missing}' ENV variable"
exit(1)
- end
+ }
hash = Digest::MD5.hexdigest("#{password}#{username}")
puts "The MD5 hash of your database password for user: #{username} -> #{hash}"
end
diff --git a/lib/tasks/plugins.rake b/lib/tasks/plugins.rake
index e73dd7e68df..d6434d58ab6 100644
--- a/lib/tasks/plugins.rake
+++ b/lib/tasks/plugins.rake
@@ -1,7 +1,7 @@
namespace :plugins do
- desc 'Validate existing plugins'
+ desc "Validate existing plugins"
task validate: :environment do
- puts 'Validating plugins from /plugins directory'
+ puts "Validating plugins from /plugins directory"
Gitlab::Plugin.files.each do |file|
success, message = Gitlab::Plugin.execute(file, Gitlab::DataBuilder::Push::SAMPLE_DATA)
diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake
index 78ffccc9d06..17327b57c73 100644
--- a/lib/tasks/rubocop.rake
+++ b/lib/tasks/rubocop.rake
@@ -1,5 +1,5 @@
unless Rails.env.production?
- require 'rubocop/rake_task'
+ require "rubocop/rake_task"
RuboCop::RakeTask.new
end
diff --git a/lib/tasks/scss-lint.rake b/lib/tasks/scss-lint.rake
index 250fd8699e4..e64a0d71a4a 100644
--- a/lib/tasks/scss-lint.rake
+++ b/lib/tasks/scss-lint.rake
@@ -1,8 +1,8 @@
unless Rails.env.production?
- require 'scss_lint/rake_task'
+ require "scss_lint/rake_task"
SCSSLint::RakeTask.new do |t|
- t.config = '.scss-lint.yml'
+ t.config = ".scss-lint.yml"
# See https://github.com/brigade/scss-lint/issues/726
# Hack, otherwise linter won't respect scss_files option in config file.
t.files = []
diff --git a/lib/tasks/services.rake b/lib/tasks/services.rake
index 56b81106c5f..1c0a39fbc8f 100644
--- a/lib/tasks/services.rake
+++ b/lib/tasks/services.rake
@@ -1,60 +1,60 @@
-services_template = <<-ERB
-# Services
+services_template = <<~ERB
+ # Services
-<% services.each do |service| %>
-## <%= service[:title] %>
+ <% services.each do |service| %>
+ ## <%= service[:title] %>
-<% unless service[:description].blank? %>
-<%= service[:description] %>
-<% end %>
+ <% unless service[:description].blank? %>
+ <%= service[:description] %>
+ <% end %>
-### Create/Edit <%= service[:title] %> service
+ ### Create/Edit <%= service[:title] %> service
-Set <%= service[:title] %> service for a project.
-<% unless service[:help].blank? %>
+ Set <%= service[:title] %> service for a project.
+ <% unless service[:help].blank? %>
-> <%= service[:help].gsub("\n", ' ') %>
+ > <%= service[:help].gsub("\n", ' ') %>
-<% end %>
+ <% end %>
-```
-PUT /projects/:id/services/<%= service[:dashed_name] %>
+ ```
+ PUT /projects/:id/services/<%= service[:dashed_name] %>
-```
+ ```
-Parameters:
+ Parameters:
-<% service[:params].each do |param| %>
-- `<%= param[:name] %>` <%= param[:required] ? "(**required**)" : "(optional)" %><%= [" -", param[:description]].join(" ").gsub("\n", '') unless param[:description].blank? %>
+ <% service[:params].each do |param| %>
+ - `<%= param[:name] %>` <%= param[:required] ? "(**required**)" : "(optional)" %><%= [" -", param[:description]].join(" ").gsub("\n", '') unless param[:description].blank? %>
-<% end %>
+ <% end %>
-### Delete <%= service[:title] %> service
+ ### Delete <%= service[:title] %> service
-Delete <%= service[:title] %> service for a project.
+ Delete <%= service[:title] %> service for a project.
-```
-DELETE /projects/:id/services/<%= service[:dashed_name] %>
+ ```
+ DELETE /projects/:id/services/<%= service[:dashed_name] %>
-```
+ ```
-### Get <%= service[:title] %> service settings
+ ### Get <%= service[:title] %> service settings
-Get <%= service[:title] %> service settings for a project.
+ Get <%= service[:title] %> service settings for a project.
-```
-GET /projects/:id/services/<%= service[:dashed_name] %>
+ ```
+ GET /projects/:id/services/<%= service[:dashed_name] %>
-```
+ ```
-<% end %>
+ <% end %>
ERB
namespace :services do
task doc: :environment do
- services = Service.available_services_names.map do |s|
+ services = Service.available_services_names.map { |s|
service_start = Time.now
klass = "#{s}_service".classify.constantize
@@ -66,30 +66,30 @@ namespace :services do
service_hash[:dashed_name] = s.dasherize
service_hash[:description] = service.description
service_hash[:help] = service.help
- service_hash[:params] = service.fields.map do |p|
+ service_hash[:params] = service.fields.map { |p|
param_hash = {}
param_hash[:name] = p[:name]
param_hash[:description] = p[:placeholder] || p[:title]
- param_hash[:required] = klass.validators_on(p[:name].to_sym).any? do |v|
+ param_hash[:required] = klass.validators_on(p[:name].to_sym).any? { |v|
v.class == ActiveRecord::Validations::PresenceValidator
- end
+ }
param_hash
- end
+ }
service_hash[:params].sort_by! { |p| p[:required] ? 0 : 1 }
puts "Collected data for: #{service.title}, #{Time.now - service_start}"
service_hash
- end
+ }
doc_start = Time.now
- doc_path = File.join(Rails.root, 'doc', 'api', 'services.md')
+ doc_path = File.join(Rails.root, "doc", "api", "services.md")
- result = ERB.new(services_template, 0, '>')
+ result = ERB.new(services_template, 0, ">")
.result(OpenStruct.new(services: services).instance_eval { binding })
- File.open(doc_path, 'w') do |f|
+ File.open(doc_path, "w") do |f|
f.write result
end
diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake
index dd9ce86f7ca..68c61cb9099 100644
--- a/lib/tasks/sidekiq.rake
+++ b/lib/tasks/sidekiq.rake
@@ -1,21 +1,21 @@
namespace :sidekiq do
desc "GitLab | Stop sidekiq"
task :stop do
- system(*%w(bin/background_jobs stop))
+ system("bin/background_jobs", "stop")
end
desc "GitLab | Start sidekiq"
task :start do
- system(*%w(bin/background_jobs start))
+ system("bin/background_jobs", "start")
end
- desc 'GitLab | Restart sidekiq'
+ desc "GitLab | Restart sidekiq"
task :restart do
- system(*%w(bin/background_jobs restart))
+ system("bin/background_jobs", "restart")
end
desc "GitLab | Start sidekiq with launchd on Mac OS X"
task :launchd do
- system(*%w(bin/background_jobs start_no_deamonize))
+ system("bin/background_jobs", "start_no_deamonize")
end
end
diff --git a/lib/tasks/spec.rake b/lib/tasks/spec.rake
index 2eddcb3c777..f7d47c1b945 100644
--- a/lib/tasks/spec.rake
+++ b/lib/tasks/spec.rake
@@ -1,56 +1,56 @@
-Rake::Task["spec"].clear if Rake::Task.task_defined?('spec')
+Rake::Task["spec"].clear if Rake::Task.task_defined?("spec")
namespace :spec do
- desc 'GitLab | Rspec | Run request specs'
+ desc "GitLab | Rspec | Run request specs"
task :api do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @api)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @api],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run feature specs'
+ desc "GitLab | Rspec | Run feature specs"
task :feature do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @feature)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @feature],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run model specs'
+ desc "GitLab | Rspec | Run model specs"
task :models do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @models)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @models],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run service specs'
+ desc "GitLab | Rspec | Run service specs"
task :services do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @services)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @services],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run lib specs'
+ desc "GitLab | Rspec | Run lib specs"
task :lib do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @lib)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @lib],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run other specs'
+ desc "GitLab | Rspec | Run other specs"
task :other do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services],
]
run_commands(cmds)
end
@@ -59,14 +59,14 @@ end
desc "GitLab | Run specs"
task :spec do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec)
+ %w[rake gitlab:setup],
+ %w[rspec spec],
]
run_commands(cmds)
end
def run_commands(cmds)
cmds.each do |cmd|
- system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
+ system({"RAILS_ENV" => "test", "force" => "yes"}, *cmd) || raise("#{cmd} failed!")
end
end
diff --git a/lib/tasks/tokens.rake b/lib/tasks/tokens.rake
index eec024f9bbb..99ddf008434 100644
--- a/lib/tasks/tokens.rake
+++ b/lib/tasks/tokens.rake
@@ -1,7 +1,7 @@
-require_relative '../../app/models/concerns/token_authenticatable.rb'
-require_relative '../../app/models/concerns/token_authenticatable_strategies/base.rb'
-require_relative '../../app/models/concerns/token_authenticatable_strategies/insecure.rb'
-require_relative '../../app/models/concerns/token_authenticatable_strategies/digest.rb'
+require_relative "../../app/models/concerns/token_authenticatable.rb"
+require_relative "../../app/models/concerns/token_authenticatable_strategies/base.rb"
+require_relative "../../app/models/concerns/token_authenticatable_strategies/insecure.rb"
+require_relative "../../app/models/concerns/token_authenticatable_strategies/digest.rb"
namespace :tokens do
desc "Reset all GitLab incoming email tokens"
@@ -27,7 +27,7 @@ end
class TmpUser < ActiveRecord::Base
include TokenAuthenticatable
- self.table_name = 'users'
+ self.table_name = "users"
add_authentication_token_field :incoming_email_token, token_generator: -> { SecureRandom.hex.to_i(16).to_s(36) }
add_authentication_token_field :feed_token
diff --git a/lib/tasks/yarn.rake b/lib/tasks/yarn.rake
index 2ac88a039e7..8d2a1339821 100644
--- a/lib/tasks/yarn.rake
+++ b/lib/tasks/yarn.rake
@@ -1,40 +1,39 @@
-
namespace :yarn do
- desc 'Ensure Yarn is installed'
+ desc "Ensure Yarn is installed"
task :available do
- unless system('yarn --version', out: File::NULL)
+ unless system("yarn --version", out: File::NULL)
warn(
- 'Error: Yarn executable was not detected in the system.'.color(:red),
- 'Download Yarn at https://yarnpkg.com/en/docs/install'.color(:green)
+ "Error: Yarn executable was not detected in the system.".color(:red),
+ "Download Yarn at https://yarnpkg.com/en/docs/install".color(:green)
)
abort
end
end
- desc 'Ensure Node dependencies are installed'
- task check: ['yarn:available'] do
- unless system('yarn check --ignore-engines', out: File::NULL)
+ desc "Ensure Node dependencies are installed"
+ task check: ["yarn:available"] do
+ unless system("yarn check --ignore-engines", out: File::NULL)
warn(
- 'Error: You have unmet dependencies. (`yarn check` command failed)'.color(:red),
- 'Run `yarn install` to install missing modules.'.color(:green)
+ "Error: You have unmet dependencies. (`yarn check` command failed)".color(:red),
+ "Run `yarn install` to install missing modules.".color(:green)
)
abort
end
end
- desc 'Install Node dependencies with Yarn'
- task install: ['yarn:available'] do
- unless system('yarn install --pure-lockfile --ignore-engines')
- abort 'Error: Unable to install node modules.'.color(:red)
+ desc "Install Node dependencies with Yarn"
+ task install: ["yarn:available"] do
+ unless system("yarn install --pure-lockfile --ignore-engines")
+ abort "Error: Unable to install node modules.".color(:red)
end
end
- desc 'Remove Node dependencies'
+ desc "Remove Node dependencies"
task :clobber do
- warn 'Purging ./node_modules directory'.color(:red)
- FileUtils.rm_rf 'node_modules'
+ warn "Purging ./node_modules directory".color(:red)
+ FileUtils.rm_rf "node_modules"
end
end
-desc 'Install Node dependencies with Yarn'
-task yarn: ['yarn:install']
+desc "Install Node dependencies with Yarn"
+task yarn: ["yarn:install"]