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

ALLOWED = [
4
  # Can be fixed once Rugged is no longer used in production. Doesn't make Rugged calls.
5 6 7 8 9 10 11 12 13 14 15 16
  'config/initializers/8_metrics.rb',

  # Can be deleted once wiki's are fully (mandatory) migrated
  'config/initializers/gollum.rb',

  # Needs to be migrated, https://gitlab.com/gitlab-org/gitaly/issues/953
  'lib/gitlab/bare_repository_import/repository.rb',

  # Needs to be migrated, https://gitlab.com/gitlab-org/gitaly/issues/954
  'lib/tasks/gitlab/cleanup.rake',

  # The only place where Rugged code is still allowed in production
17 18 19 20
  'lib/gitlab/git/',

  # Needed to avoid using the git binary to validate a branch name
  'lib/gitlab/git_ref_validator.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 26 27 28 29 30 31 32 33 34 35 36 37
rugged_lines = rugged_lines.reject { |l| l.start_with?(*ALLOWED) }
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)