lint-rugged 1.2 KB
Newer Older
1 2 3
#!/usr/bin/env ruby

ALLOWED = [
4
  # Needed to handle repositories that are not in any storage
5 6
  'lib/gitlab/bare_repository_import/repository.rb',

A
Ahmad Hassan 已提交
7
  # Needed to avoid using the git binary to validate a branch name
8 9 10 11 12
  'lib/gitlab/git_ref_validator.rb',

  # Reverted Rugged calls due to Gitaly atop NFS performance
  # See https://docs.gitlab.com/ee/development/gitaly.html#legacy-rugged-code.
  'lib/gitlab/git/rugged_impl/',
13 14 15
  'lib/gitlab/gitaly_client/storage_settings.rb',

  # Needed for logging
S
Stan Hu 已提交
16
  'config/initializers/peek.rb',
17 18
  'config/initializers/lograge.rb',
  'lib/gitlab/grape_logging/loggers/perf_logger.rb',
S
Stan Hu 已提交
19 20
  'lib/gitlab/rugged_instrumentation.rb',
  'lib/peek/views/rugged.rb'
21 22 23
].freeze

rugged_lines = IO.popen(%w[git grep -i -n rugged -- app config lib], &:read).lines
24
rugged_lines = rugged_lines.select { |l| /^[^:]*\.rb:/ =~ l }
25
rugged_lines = rugged_lines.reject { |l| l.start_with?(*ALLOWED) }
26
rugged_lines = rugged_lines.reject { |l| /(include|prepend) Gitlab::Git::RuggedImpl/ =~ l}
27 28 29 30 31 32 33 34 35 36 37 38
rugged_lines = rugged_lines.reject do |line|
  code, _comment = line.split('# ', 2)
  code !~ /rugged/i
end

exit if rugged_lines.empty?

puts "Using Rugged is only allowed in test and #{ALLOWED}\n\n"

puts rugged_lines

exit(false)