diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-08-06 12:46:18 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-08-06 12:46:18 +0300 |
commit | 45f91bf4b223cb01239137e1d696156ab5d53b39 (patch) | |
tree | aa16b4efa2cfe752e4f7eeb781166ece7bf3069a | |
parent | b9268c5dd8ab74e0fcbd75046ced98d7b637918d (diff) | |
parent | c6a8032e1af21da05280c1c01b489a282868af89 (diff) |
Merge branch 'jv-fix-proto-version-check' into 'master'
Update ruby proto version file during release
Closes #1829
See merge request gitlab-org/gitaly!1391
-rwxr-xr-x | _support/generate-proto-ruby | 10 | ||||
-rwxr-xr-x | _support/release | 25 |
2 files changed, 23 insertions, 12 deletions
diff --git a/_support/generate-proto-ruby b/_support/generate-proto-ruby index a9ceab7d4..796b6ccb4 100755 --- a/_support/generate-proto-ruby +++ b/_support/generate-proto-ruby @@ -39,16 +39,6 @@ def write_ruby_requires <% end %> EOT open(gem_root, 'w') { |f| f.write(gem_root_template.result(binding)) } - - version_rb_template = <<~EOT - # This file was auto-generated by #{$0} - module Gitaly - VERSION = "#{File.read('VERSION').chomp}" - end - EOT - version_rb = File.join(RUBY_PREFIX, RUBY_VERSION_FILE) - open(version_rb, 'w') { |f| f.write(version_rb_template) } - end main diff --git a/_support/release b/_support/release index 443f013e8..712fdfc27 100755 --- a/_support/release +++ b/_support/release @@ -19,7 +19,7 @@ def main(version) run!(%w[git diff --quiet --cached --exit-code]) tag_name = "v#{version}" - write_version_file(version) + write_version_files(version) run!(%W[_support/generate_changelog #{version}]) run!(%w[git add changelogs CHANGELOG.md]) @@ -35,10 +35,31 @@ def main(version) puts "If this is not a security release you can now publish this tag to gitlab.com:\n\n\t_support/publish #{tag_name}\n\n" end -def write_version_file(version) +def write_version_files(version) version_file = 'VERSION' open(version_file, 'w') { |f| f.puts version } run!(%W[git add #{version_file}]) + + ruby_proto_version_file = 'ruby/proto/gitaly/version.rb' + open(ruby_proto_version_file, 'w') do |f| + f.puts <<~PROTO_VERSION + # This file was auto-generated by #{$0} + module Gitaly + VERSION = '#{version}' + end + PROTO_VERSION + end + + # Generating code is tricky. Let's actually load the gem, and inspect + # the version constant. + check = capture!(%W[ruby -Iruby/proto -rgitaly -e #{'print Gitaly::VERSION'}]) + unless check == version + puts "fatal: ruby proto version check failed. \n\n" + puts capture!(%w[git diff]) + abort + end + + run!(%W[git add #{ruby_proto_version_file}]) end def error(msg) |