Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/flay.rake2
-rw-r--r--lib/tasks/gettext.rake24
-rw-r--r--lib/tasks/lint.rake22
3 files changed, 32 insertions, 16 deletions
diff --git a/lib/tasks/flay.rake b/lib/tasks/flay.rake
index 4b4881cecb8..4bec013a141 100644
--- a/lib/tasks/flay.rake
+++ b/lib/tasks/flay.rake
@@ -1,6 +1,6 @@
desc 'Code duplication analyze via flay'
task :flay do
- output = `bundle exec flay --mass 35 app/ lib/gitlab/ 2> #{File::NULL}`
+ output = `bundle exec flay --mass 35 app/ lib/gitlab/ ee/ 2> #{File::NULL}`
if output.include?("Similar code found") || output.include?("IDENTICAL code found")
puts output
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index d52c419d66b..21998dd2f5b 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -4,7 +4,7 @@ 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(app lib config #{locale_path}).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(
@@ -16,7 +16,6 @@ namespace :gettext do
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/33014#note_31218998
FileUtils.touch(File.join(Rails.root, 'locale/gitlab.pot'))
- Rake::Task['gettext:pack'].invoke
Rake::Task['gettext:po_to_json'].invoke
end
@@ -53,25 +52,34 @@ namespace :gettext do
task :updated_check do
# Removing all pre-translated files speeds up `gettext:find` as the
# files don't need to be merged.
- `rm locale/*/gitlab.po`
+ # Having `LC_MESSAGES/gitlab.mo files present also confuses the output.
+ FileUtils.rm Dir['locale/**/gitlab.*']
+
+ # Make sure we start out with a clean pot.file
+ `git checkout -- locale/gitlab.pot`
# `gettext:find` writes touches to temp files to `stderr` which would cause
- # `static-analysis` to report failures. We can ignore these
- silence_stream(STDERR) { Rake::Task['gettext:find'].invoke }
+ # `static-analysis` to report failures. We can ignore these.
+ silence_stream($stderr) do
+ Rake::Task['gettext:find'].invoke
+ end
- changed_files = `git diff --name-only`.lines.map(&:strip)
+ pot_diff = `git diff -- locale/gitlab.pot`.strip
# reset the locale folder for potential next tasks
`git checkout -- locale`
- if changed_files.include?('locale/gitlab.pot')
+ if pot_diff.present?
raise <<~MSG
Newly translated strings found, please add them to `gitlab.pot` by running:
- bundle exec rake gettext:find; git checkout -- locale/*/gitlab.po;
+ rm locale/**/gitlab.*; bin/rake gettext:find; git checkout -- locale/*/gitlab.po
Then commit and push the resulting changes to `locale/gitlab.pot`.
+ The diff was:
+
+ #{pot_diff}
MSG
end
end
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index b5a9cddaacb..006fcdd31a4 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -17,13 +17,22 @@ unless Rails.env.production?
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
+ end
+
desc "GitLab | lint | Run several lint checks"
task :all do
status = 0
%w[
config_lint
- haml_lint
+ lint:haml
scss_lint
flay
gettext:lint
@@ -39,13 +48,12 @@ unless Rails.env.production?
$stderr.reopen(wr_err)
begin
- begin
- Rake::Task[task].invoke
- rescue RuntimeError # The haml_lint tasks raise a RuntimeError
- exit(1)
- end
+ Rake::Task[task].invoke
rescue SystemExit => ex
- msg = "*** Rake task #{task} failed with the following error(s):"
+ msg = "*** Rake task #{task} exited:"
+ raise ex
+ rescue => ex
+ msg = "*** Rake task #{task} raised #{ex.class}:"
raise ex
ensure
$stdout.reopen(stdout)