47 lines
1.2 KiB
Ruby
Raw Normal View History

2020-11-25 17:03:23 +01:00
# typed: true
# frozen_string_literal: true
require "bintray"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2020-10-20 12:03:48 +02:00
extend T::Sig
2016-09-26 01:44:51 +02:00
module_function
2020-10-20 12:03:48 +02:00
sig { returns(CLI::Parser) }
def mirror_args
Homebrew::CLI::Parser.new do
description <<~EOS
Reupload the stable URL of a formula to Bintray for use as a mirror.
2018-09-28 21:39:52 +05:30
EOS
2020-06-25 12:01:52 -04:00
flag "--bintray-org=",
description: "Upload to the specified Bintray organisation (default: `homebrew`)."
flag "--bintray-repo=",
description: "Upload to the specified Bintray repository (default: `mirror`)."
switch "--no-publish",
description: "Upload to Bintray, but don't publish."
2020-07-30 18:40:10 +02:00
2021-01-10 14:26:40 -05:00
named_args :formula, min: 1
hide_from_man_page!
end
end
def mirror
2020-07-23 01:22:25 +02:00
args = mirror_args.parse
odeprecated "brew mirror (Bintray will be shut down on 1st May 2021)"
bintray_org = args.bintray_org || "homebrew"
bintray_repo = args.bintray_repo || "mirror"
bintray = Bintray.new(org: bintray_org)
args.named.to_formulae.each do |formula|
mirror_url = bintray.mirror_formula(formula, repo: bintray_repo, publish_package: !args.no_publish?)
ohai "Mirrored #{formula.full_name} to #{mirror_url}!"
end
end
end