Port Homebrew::DevCmd::UpdateTest

This commit is contained in:
Douglas Eichelberger 2024-03-21 22:16:13 -07:00
parent c789bf4475
commit 084f63ef22
3 changed files with 164 additions and 145 deletions

View File

@ -1,11 +1,16 @@
# typed: true
# frozen_string_literal: true
require "abstract_command"
require "cli/parser"
require "fileutils"
module Homebrew
sig { returns(CLI::Parser) }
def self.update_test_args
Homebrew::CLI::Parser.new do
module DevCmd
class UpdateTest < AbstractCommand
include FileUtils
cmd_args do
description <<~EOS
Run a test of `brew update` with a new repository clone.
If no options are passed, use `origin/master` as the start commit.
@ -21,11 +26,9 @@ module Homebrew
named_args :none
end
end
def self.update_test
args = update_test_args.parse
sig { override.void }
def run
# Avoid `update-report.rb` tapping Homebrew/homebrew-core
ENV["HOMEBREW_UPDATE_TEST"] = "1"
@ -137,7 +140,9 @@ module Homebrew
FileUtils.rm_rf "update-test" unless args.keep_tmp?
end
def self.git_tags
private
def git_tags
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
if tags.blank?
tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
@ -148,5 +153,7 @@ module Homebrew
tags
end
end
end
end
require "extend/os/dev-cmd/update-test"

View File

@ -2,9 +2,12 @@
# frozen_string_literal: true
module Homebrew
class << self
module DevCmd
class UpdateTest < AbstractCommand
alias generic_git_tags git_tags
private
sig { returns(String) }
def git_tags
tags = generic_git_tags
@ -13,3 +16,4 @@ module Homebrew
end
end
end
end

View File

@ -0,0 +1,8 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "dev-cmd/update-test"
RSpec.describe Homebrew::DevCmd::UpdateTest do
it_behaves_like "parseable arguments"
end