a99bf447a2
Cleanup code, and refactor tests that still use Rugged. After this, there should be no Rugged code that access the instance's repositories on non-test environments. There is still some rugged code for other tasks like the repository import task, but since it doesn't access any repository storage path it can stay.
25 lines
707 B
Ruby
Executable file
25 lines
707 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
ALLOWED = [
|
|
# Needed to handle repositories that are not in any storage
|
|
'lib/gitlab/bare_repository_import/repository.rb',
|
|
|
|
# Needed to avoid using the git binary to validate a branch name
|
|
'lib/gitlab/git_ref_validator.rb'
|
|
].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) }
|
|
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)
|