| 
									
										
										
										
											2020-11-25 17:03:23 +01:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-27 20:27:42 +01:00
										 |  |  | require "bintray" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2018-04-10 18:37:15 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-20 11:00:51 +01:00
										 |  |  | 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) } | 
					
						
							| 
									
										
										
										
											2018-07-30 18:25:38 +05:30
										 |  |  |   def mirror_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							| 
									
										
										
										
											2021-01-15 15:04:02 -05:00
										 |  |  |       description <<~EOS | 
					
						
							| 
									
										
										
										
											2020-04-18 12:13:43 -04:00
										 |  |  |         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`)." | 
					
						
							| 
									
										
										
										
											2020-06-20 21:55:49 +10:00
										 |  |  |       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
 | 
					
						
							| 
									
										
										
										
											2018-04-01 16:47:30 +05:30
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-07-30 18:25:38 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def mirror | 
					
						
							| 
									
										
										
										
											2020-07-23 01:22:25 +02:00
										 |  |  |     args = mirror_args.parse | 
					
						
							| 
									
										
										
										
											2018-04-01 16:47:30 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-27 20:27:42 +01:00
										 |  |  |     bintray_org = args.bintray_org || "homebrew" | 
					
						
							| 
									
										
										
										
											2020-06-20 21:55:49 +10:00
										 |  |  |     bintray_repo = args.bintray_repo || "mirror" | 
					
						
							| 
									
										
										
										
											2020-04-27 20:27:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bintray = Bintray.new(org: bintray_org) | 
					
						
							| 
									
										
										
										
											2016-05-20 11:00:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |     args.named.to_formulae.each do |formula| | 
					
						
							| 
									
										
										
										
											2020-06-20 21:55:49 +10:00
										 |  |  |       mirror_url = bintray.mirror_formula(formula, repo: bintray_repo, publish_package: !args.no_publish?) | 
					
						
							| 
									
										
										
										
											2020-06-08 17:48:28 +02:00
										 |  |  |       ohai "Mirrored #{formula.full_name} to #{mirror_url}!" | 
					
						
							| 
									
										
										
										
											2016-05-20 11:00:51 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |