Skip to content
Snippets Groups Projects
Commit eb173e74 authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab)
Browse files

Merge branch 'ruby-generation' into 'master'

Always regenerate ruby, not just on release

See merge request !9
parents 84b3ffd0 cd67addf
No related branches found
No related tags found
1 merge request!9Always regenerate ruby, not just on release
Pipeline #
#!/usr/bin/env ruby
require 'erb'
require 'fileutils'
require_relative 'run.rb'
 
PROTO_INCLUDE = '.'
PROTO_FILES = Dir['*.proto'].sort
RUBY_PREFIX = 'ruby/lib'
RUBY_VERSION_FILE = 'gitaly/version.rb'
 
ENV['PATH'] = [
File.join(ENV['GOPATH'], 'bin'),
Loading
Loading
@@ -12,9 +18,28 @@ ENV['PATH'] = [
].join(':')
 
def main
FileUtils.rm(Dir['go/**/*.pb.go'])
run!(%W[protoc -I #{PROTO_INCLUDE}] + PROTO_FILES + %w[--go_out=plugins=grpc:go])
ruby_lib = 'ruby/lib/gitaly'
run!(%W[grpc_tools_ruby_protoc -I #{PROTO_INCLUDE} --ruby_out=#{ruby_lib} --grpc_out=#{ruby_lib}] + PROTO_FILES)
FileUtils.rm(Dir[File.join(RUBY_PREFIX, '**/*_pb.rb')])
ruby_lib_gitaly = File.join(RUBY_PREFIX, 'gitaly')
run!(%W[grpc_tools_ruby_protoc -I #{PROTO_INCLUDE} --ruby_out=#{ruby_lib_gitaly} --grpc_out=#{ruby_lib_gitaly}] + PROTO_FILES)
write_ruby_requires
end
def write_ruby_requires
requires = Dir.chdir(RUBY_PREFIX) { Dir['gitaly/*_services_pb.rb'] }.sort
abort "No auto-generated Ruby service files found" if requires.empty?
requires.unshift(RUBY_VERSION_FILE)
gem_root = File.join(RUBY_PREFIX, 'gitaly.rb')
gem_root_template = ERB.new <<EOT
# This file is generated by #{File.basename($0)}. Do not edit.
$:.unshift(File.expand_path('../gitaly', __FILE__))
<% requires.each do |f| %>
require '<%= f.sub(/\.rb$/, '') %>'
<% end %>
EOT
open(gem_root, 'w') { |f| f.write(gem_root_template.result(binding)) }
end
 
main
Loading
Loading
@@ -13,7 +13,6 @@ def main(version)
run!(%w[git diff --quiet --exit-code])
puts 'Testing for staged changes'
run!(%w[git diff --quiet --cached --exit-code])
write_ruby_requires
write_version_files(version)
version_msg = "Version #{version}"
run!(%W[git commit -m #{version_msg}])
Loading
Loading
@@ -53,22 +52,6 @@ EOT
run!(%W[git add #{version_rb}])
end
 
def write_ruby_requires
requires = Dir.chdir(RUBY_PREFIX) { Dir['gitaly/*_services_pb.rb'] }
abort "No auto-generated Ruby service files found" if requires.empty?
requires.unshift(RUBY_VERSION_FILE)
gem_root = File.join(RUBY_PREFIX, 'gitaly.rb')
gem_root_template = ERB.new <<EOT
# This file is generated by _support/release. Do not edit.
$:.unshift(File.expand_path('../gitaly', __FILE__))
<% requires.each do |f| %>
require '<%= f.sub(/\.rb$/, '') %>'
<% end %>
EOT
open(gem_root, 'w') { |f| f.write(gem_root_template.result(binding)) }
run!(%W[git add #{gem_root}])
end
def error(msg)
warn "#{$0}: #{msg}"
end
Loading
Loading
# This file is generated by _support/release. Do not edit.
# This file is generated by generate-from-proto. Do not edit.
$:.unshift(File.expand_path('../gitaly', __FILE__))
 
require 'gitaly/version'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment