brew/Library/Homebrew/dev-cmd/vendor-gems.rb

59 lines
1.2 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "formula"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2020-10-20 12:03:48 +02:00
extend T::Sig
module_function
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
def vendor_gems_args
Homebrew::CLI::Parser.new do
description <<~EOS
Install and commit Homebrew's vendored gems.
EOS
2020-07-30 18:40:10 +02:00
comma_array "--update",
description: "Update all vendored Gems to the latest version."
2021-01-10 14:26:40 -05:00
named_args :none
end
end
sig { void }
def vendor_gems
args = vendor_gems_args.parse
Homebrew.install_bundler!
ohai "cd #{HOMEBREW_LIBRARY_PATH}"
HOMEBREW_LIBRARY_PATH.cd do
if args.update
ohai "bundle update"
safe_system "bundle", "update", *args.update
ohai "git add Gemfile.lock"
system "git", "add", "Gemfile.lock"
end
ohai "bundle install --standalone"
safe_system "bundle", "install", "--standalone"
ohai "bundle pristine"
safe_system "bundle", "pristine"
ohai "git add vendor/bundle"
system "git", "add", "vendor/bundle"
Utils::Git.set_name_email!
Utils::Git.setup_gpg!
ohai "git commit"
system "git", "commit", "--message", "brew vendor-gems: commit updates."
end
end
end