debian-mirror-gitlab/scripts/lint-rugged

32 lines
1,022 B
Text
Raw Normal View History

2018-03-17 18:26:18 +05:30
#!/usr/bin/env ruby
ALLOWED = [
2018-12-05 23:21:45 +05:30
# Needed to handle repositories that are not in any storage
2018-03-17 18:26:18 +05:30
'lib/gitlab/bare_repository_import/repository.rb',
2018-11-18 11:00:15 +05:30
# Needed to avoid using the git binary to validate a branch name
2019-05-03 19:53:19 +05:30
'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/',
'lib/gitlab/gitaly_client/storage_settings.rb'
2018-03-17 18:26:18 +05:30
].freeze
rugged_lines = IO.popen(%w[git grep -i -n rugged -- app config lib], &:read).lines
rugged_lines = rugged_lines.select { |l| /^[^:]*\.rb:/ =~ l }
rugged_lines = rugged_lines.reject { |l| l.start_with?(*ALLOWED) }
2019-05-03 19:53:19 +05:30
rugged_lines = rugged_lines.reject { |l| /(include|prepend) Gitlab::Git::RuggedImpl/ =~ l}
2018-03-17 18:26:18 +05:30
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)