| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2020-09-07 13:00:02 -04:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-05 17:17:03 -05:00
										 |  |  | # Helper module for handling `disable!` and `deprecate!`. | 
					
						
							| 
									
										
										
										
											2020-09-07 13:00:02 -04:00
										 |  |  | # | 
					
						
							|  |  |  | # @api private | 
					
						
							|  |  |  | module DeprecateDisable | 
					
						
							|  |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   DEPRECATE_DISABLE_REASONS = { | 
					
						
							|  |  |  |     does_not_build:      "does not build", | 
					
						
							|  |  |  |     no_license:          "has no license", | 
					
						
							|  |  |  |     repo_archived:       "has an archived upstream repository", | 
					
						
							|  |  |  |     repo_removed:        "has a removed upstream repository", | 
					
						
							|  |  |  |     unmaintained:        "is not maintained upstream", | 
					
						
							|  |  |  |     unsupported:         "is not supported upstream", | 
					
						
							|  |  |  |     deprecated_upstream: "is deprecated upstream", | 
					
						
							|  |  |  |     versioned_formula:   "is a versioned formula", | 
					
						
							| 
									
										
										
										
											2021-11-15 19:34:19 +01:00
										 |  |  |     checksum_mismatch:   "was built with an initially released source file that had "\ | 
					
						
							|  |  |  |                          "a different checksum than the current one. " \ | 
					
						
							|  |  |  |                          "Upstream's repository might have been compromised. " \ | 
					
						
							|  |  |  |                          "We can re-package this once upstream has confirmed that they retagged their release", | 
					
						
							| 
									
										
										
										
											2020-09-07 13:00:02 -04:00
										 |  |  |   }.freeze | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def deprecate_disable_info(formula) | 
					
						
							|  |  |  |     if formula.deprecated? | 
					
						
							|  |  |  |       type = :deprecated | 
					
						
							|  |  |  |       reason = formula.deprecation_reason | 
					
						
							| 
									
										
										
										
											2021-01-07 13:49:05 -08:00
										 |  |  |     elsif formula.disabled? | 
					
						
							| 
									
										
										
										
											2020-09-07 13:00:02 -04:00
										 |  |  |       type = :disabled | 
					
						
							|  |  |  |       reason = formula.disable_reason | 
					
						
							| 
									
										
										
										
											2021-01-07 13:49:05 -08:00
										 |  |  |     else | 
					
						
							|  |  |  |       return | 
					
						
							| 
									
										
										
										
											2020-09-07 13:00:02 -04:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     reason = DEPRECATE_DISABLE_REASONS[reason] if DEPRECATE_DISABLE_REASONS.key? reason | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [type, reason] | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |