summaryrefslogtreecommitdiff
path: root/task/build_metadata.rake
blob: a896ed4801f40d065ab8762f027f91599e6f4a5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true
file "lib/bundler/generated/build_metadata.rb" => [".git/HEAD", ".git/logs/HEAD", __FILE__, :git_hooks] do |t|
  sh "git update-index --assume-unchanged #{t.name}", :verbose => false

  build_metadata = {
    :built_at => BUNDLER_SPEC.date.strftime("%Y-%m-%d"),
    :git_sha => `git rev-parse --short HEAD`.strip,
    :release => Rake::Task["release"].instance_variable_get(:@already_invoked),
  }

  File.open(t.name, "w") {|f| f << <<-RUBY }
# frozen_string_literal: true

module Bundler
  BUILD_METADATA = {
#{build_metadata.sort.map {|k, v| "    #{k.inspect} => #{BUNDLER_SPEC.send(:ruby_code, v)}," }.join("\n")}
  }.freeze
end
  RUBY
end