Merge pull request #14567 from hyuraku/apply-extend/os-to-dev-cmd/update-test

apply `extend/os` to `dev-cmd/update-test`
This commit is contained in:
Mike McQuaid 2023-02-09 14:59:48 +00:00 committed by GitHub
commit 0c74105536
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 10 deletions

View File

@ -2,6 +2,7 @@
# frozen_string_literal: true
require "cli/parser"
require "extend/os/dev-cmd/update-test"
module Homebrew
extend T::Sig
@ -60,16 +61,7 @@ module Homebrew
elsif (date = args.before)
Utils.popen_read("git", "rev-list", "-n1", "--before=#{date}", "origin/master").chomp
elsif args.to_tag?
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
if tags.blank?
tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
safe_system "git", "fetch", "--tags", "--depth=1"
Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
# TODO: Refactor and move to extend/os
elsif OS.linux? # rubocop:disable Homebrew/MoveToExtendOS
Utils.popen_read("git tag --list | sort -rV")
end
end
tags = git_tags
current_tag, previous_tag, = tags.lines
current_tag = current_tag.to_s.chomp
odie "Could not find current tag in:\n#{tags}" if current_tag.empty?
@ -148,4 +140,17 @@ module Homebrew
ensure
FileUtils.rm_rf "update-test" unless args.keep_tmp?
end
def git_tags
tags = Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
if tags.blank?
tags = if (HOMEBREW_REPOSITORY/".git/shallow").exist?
safe_system "git", "fetch", "--tags", "--depth=1"
Utils.popen_read("git", "tag", "--list", "--sort=-version:refname")
end
end
tags
end
alias generic_git_tags git_tags
end

View File

@ -0,0 +1,4 @@
# typed: strict
# frozen_string_literal: true
require "extend/os/linux/dev-cmd/update-test" if OS.linux?

View File

@ -0,0 +1,14 @@
# typed: false
# frozen_string_literal: true
module Homebrew
extend T::Sig
module_function
def git_tags
tags = generic_git_tags
tags = Utils.popen_read("git tag --list | sort -rV") if tags.blank?
tags
end
end