| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "formula" | 
					
						
							|  |  |  | require "ostruct" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  | require "cask/caskroom" | 
					
						
							| 
									
										
										
										
											2020-07-31 11:35:45 -04:00
										 |  |  | require "dependencies_helpers" | 
					
						
							| 
									
										
										
										
											2010-09-25 12:49:09 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   extend T::Sig | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-23 02:00:44 +02:00
										 |  |  |   extend DependenciesHelpers | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(CLI::Parser) } | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |   def deps_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							| 
									
										
										
										
											2021-01-15 15:04:02 -05:00
										 |  |  |       description <<~EOS | 
					
						
							| 
									
										
										
										
											2019-03-14 16:44:17 -04:00
										 |  |  |         Show dependencies for <formula>. Additional options specific to <formula> | 
					
						
							|  |  |  |         may be appended to the command. When given multiple formula arguments, | 
					
						
							|  |  |  |         show the intersection of dependencies for each formula. | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       EOS | 
					
						
							|  |  |  |       switch "-n", | 
					
						
							| 
									
										
										
										
											2019-08-20 00:04:14 -04:00
										 |  |  |              description: "Sort dependencies in topological order." | 
					
						
							| 
									
										
										
										
											2019-03-14 16:44:17 -04:00
										 |  |  |       switch "--1", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Only show dependencies one level down, instead of recursing." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--union", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Show the union of dependencies for multiple <formula>, instead of the intersection." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--full-name", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "List dependencies by their full name." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--include-build", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Include `:build` dependencies for <formula>." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--include-optional", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Include `:optional` dependencies for <formula>." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--include-test", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Include `:test` dependencies for <formula> (non-recursive)." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--skip-recommended", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Skip `:recommended` dependencies for <formula>." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--include-requirements", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Include requirements in addition to dependencies for <formula>." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--tree", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Show dependencies as a tree. When given multiple formula arguments, "\ | 
					
						
							|  |  |  |                           "show individual trees for each formula." | 
					
						
							| 
									
										
										
										
											2019-03-06 23:44:46 -05:00
										 |  |  |       switch "--annotate", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Mark any build, test, optional, or recommended dependencies as "\ | 
					
						
							|  |  |  |                           "such in the output." | 
					
						
							| 
									
										
										
										
											2019-03-14 16:44:17 -04:00
										 |  |  |       switch "--installed", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "List dependencies for formulae that are currently installed. If <formula> is "\ | 
					
						
							|  |  |  |                           "specified, list only its dependencies that are currently installed." | 
					
						
							| 
									
										
										
										
											2019-03-14 16:44:17 -04:00
										 |  |  |       switch "--all", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "List dependencies for all available formulae." | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       switch "--for-each", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Switch into the mode used by the `--all` option, but only list dependencies "\ | 
					
						
							| 
									
										
										
										
											2019-08-20 00:04:14 -04:00
										 |  |  |                           "for each provided <formula>, one formula per line. This is used for "\ | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |                           "debugging the `--installed`/`--all` display mode." | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |       switch "--formula", "--formulae", | 
					
						
							|  |  |  |              depends_on:  "--installed", | 
					
						
							|  |  |  |              description: "Treat all named arguments as formulae." | 
					
						
							|  |  |  |       switch "--cask", "--casks", | 
					
						
							|  |  |  |              depends_on:  "--installed", | 
					
						
							|  |  |  |              description: "Treat all named arguments as casks." | 
					
						
							| 
									
										
										
										
											2020-11-27 11:41:08 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-29 19:39:41 +00:00
										 |  |  |       conflicts "--installed", "--all" | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |       conflicts "--formula", "--cask" | 
					
						
							| 
									
										
										
										
											2019-01-30 13:18:02 +00:00
										 |  |  |       formula_options | 
					
						
							| 
									
										
										
										
											2021-01-10 14:26:40 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |       named_args [:formula, :cask] | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   def deps | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |     args = deps_args.parse | 
					
						
							| 
									
										
										
										
											2019-11-06 10:20:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Formulary.enable_factory_cache! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-06 10:20:20 +00:00
										 |  |  |     recursive = !args.send("1?") | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |     installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?) | 
					
						
							| 
									
										
										
										
											2020-02-12 22:30:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     @use_runtime_dependencies = installed && recursive && | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |                                 !args.tree? && | 
					
						
							| 
									
										
										
										
											2020-02-12 22:30:44 +01:00
										 |  |  |                                 !args.include_build? && | 
					
						
							|  |  |  |                                 !args.include_test? && | 
					
						
							|  |  |  |                                 !args.include_optional? && | 
					
						
							|  |  |  |                                 !args.skip_recommended? | 
					
						
							| 
									
										
										
										
											2019-11-06 10:20:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if args.tree? | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |       dependents = if args.named.present? | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |         sorted_dependents(args.named.to_formulae_and_casks) | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |       elsif args.installed? | 
					
						
							| 
									
										
										
										
											2020-12-29 21:06:32 +09:00
										 |  |  |         case args.only_formula_or_cask | 
					
						
							|  |  |  |         when :formula | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |           sorted_dependents(Formula.installed) | 
					
						
							| 
									
										
										
										
											2020-12-29 21:06:32 +09:00
										 |  |  |         when :cask | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:06 +00:00
										 |  |  |           sorted_dependents(Cask::Caskroom.casks) | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:06 +00:00
										 |  |  |           sorted_dependents(Formula.installed + Cask::Caskroom.casks) | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       else | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |         raise FormulaUnspecifiedError | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |       puts_deps_tree dependents, recursive: recursive, args: args | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2019-11-06 10:20:20 +00:00
										 |  |  |     elsif args.all? | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |       puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive: recursive, args: args | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2020-03-04 17:28:15 +00:00
										 |  |  |     elsif !args.no_named? && args.for_each? | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |       puts_deps sorted_dependents(args.named.to_formulae_and_casks), recursive: recursive, args: args | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       return | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 17:28:15 +00:00
										 |  |  |     if args.no_named? | 
					
						
							| 
									
										
										
										
											2019-11-06 10:20:20 +00:00
										 |  |  |       raise FormulaUnspecifiedError unless args.installed? | 
					
						
							| 
									
										
										
										
											2018-09-17 02:45:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-29 21:06:32 +09:00
										 |  |  |       sorted_dependents_formulae_and_casks = case args.only_formula_or_cask | 
					
						
							|  |  |  |       when :formula | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |         sorted_dependents(Formula.installed) | 
					
						
							| 
									
										
										
										
											2020-12-29 21:06:32 +09:00
										 |  |  |       when :cask | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:06 +00:00
										 |  |  |         sorted_dependents(Cask::Caskroom.casks) | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |       else | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:06 +00:00
										 |  |  |         sorted_dependents(Formula.installed + Cask::Caskroom.casks) | 
					
						
							| 
									
										
										
										
											2020-12-04 10:11:17 +09:00
										 |  |  |       end | 
					
						
							|  |  |  |       puts_deps sorted_dependents_formulae_and_casks, recursive: recursive, args: args | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |     dependents = dependents(args.named.to_formulae_and_casks) | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |     all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&)) | 
					
						
							| 
									
										
										
										
											2020-08-01 12:52:37 -04:00
										 |  |  |     condense_requirements(all_deps, args: args) | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |     all_deps.map! { |d| dep_display_name(d, args: args) } | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |     all_deps.uniq! | 
					
						
							| 
									
										
										
										
											2019-11-06 10:20:20 +00:00
										 |  |  |     all_deps.sort! unless args.n? | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |     puts all_deps | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-06-09 12:59:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |   def sorted_dependents(formulae_or_casks) | 
					
						
							|  |  |  |     dependents(formulae_or_casks).sort_by(&:name) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 12:52:37 -04:00
										 |  |  |   def condense_requirements(deps, args:) | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |     deps.select! { |dep| dep.is_a?(Dependency) } unless args.include_requirements? | 
					
						
							|  |  |  |     deps.select! { |dep| dep.is_a?(Requirement) || dep.installed? } if args.installed? | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |   def dep_display_name(dep, args:) | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     str = if dep.is_a? Requirement | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       if args.include_requirements? | 
					
						
							| 
									
										
										
										
											2018-01-14 13:27:43 +00:00
										 |  |  |         ":#{dep.display_s}" | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       else | 
					
						
							|  |  |  |         # This shouldn't happen, but we'll put something here to help debugging | 
					
						
							|  |  |  |         "::#{dep.name}" | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |     elsif args.full_name? | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       dep.to_formula.full_name | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       dep.name | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |     if args.annotate? | 
					
						
							| 
									
										
										
										
											2019-03-06 23:44:46 -05:00
										 |  |  |       str = "#{str} " if args.tree? | 
					
						
							|  |  |  |       str = "#{str} [build]" if dep.build? | 
					
						
							|  |  |  |       str = "#{str} [test]" if dep.test? | 
					
						
							|  |  |  |       str = "#{str} [optional]" if dep.optional? | 
					
						
							|  |  |  |       str = "#{str} [recommended]" if dep.recommended? | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     str | 
					
						
							| 
									
										
										
										
											2016-12-20 03:39:30 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-01 11:21:45 +01:00
										 |  |  |   def deps_for_dependent(d, args:, recursive: false) | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |     includes, ignores = args_includes_ignores(args) | 
					
						
							| 
									
										
										
										
											2015-03-20 21:31:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |     deps = d.runtime_dependencies if @use_runtime_dependencies | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-29 17:27:21 -04:00
										 |  |  |     if recursive | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |       deps ||= recursive_includes(Dependency, d, includes, ignores) | 
					
						
							|  |  |  |       reqs   = recursive_includes(Requirement, d, includes, ignores) | 
					
						
							| 
									
										
										
										
											2013-10-29 17:27:21 -04:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |       deps ||= reject_ignores(d.deps, ignores, includes) | 
					
						
							|  |  |  |       reqs   = reject_ignores(d.requirements, ignores, includes) | 
					
						
							| 
									
										
										
										
											2013-10-29 17:27:21 -04:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-02-27 12:56:42 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     deps + reqs.to_a | 
					
						
							| 
									
										
										
										
											2013-10-29 17:27:21 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-01 11:21:45 +01:00
										 |  |  |   def deps_for_dependents(dependents, args:, recursive: false, &block) | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |     dependents.map { |d| deps_for_dependent(d, recursive: recursive, args: args) }.reduce(&block) | 
					
						
							| 
									
										
										
										
											2013-06-22 12:54:45 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-01 11:21:45 +01:00
										 |  |  |   def puts_deps(dependents, args:, recursive: false) | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |     dependents.each do |dependent| | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |       deps = deps_for_dependent(dependent, recursive: recursive, args: args) | 
					
						
							| 
									
										
										
										
											2020-08-01 12:52:37 -04:00
										 |  |  |       condense_requirements(deps, args: args) | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  |       deps.sort_by!(&:name) | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |       deps.map! { |d| dep_display_name(d, args: args) } | 
					
						
							|  |  |  |       puts "#{dependent.full_name}: #{deps.join(" ")}" | 
					
						
							| 
									
										
										
										
											2016-12-20 03:39:30 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2013-06-22 12:54:45 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-01 11:21:45 +01:00
										 |  |  |   def puts_deps_tree(dependents, args:, recursive: false) | 
					
						
							| 
									
										
										
										
											2020-07-27 19:12:16 -04:00
										 |  |  |     dependents.each do |d| | 
					
						
							|  |  |  |       puts d.full_name | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       @dep_stack = [] | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |       recursive_deps_tree(d, "", recursive, args: args) | 
					
						
							| 
									
										
										
										
											2013-06-22 12:54:45 -05:00
										 |  |  |       puts | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |   def recursive_deps_tree(f, prefix, recursive, args:) | 
					
						
							|  |  |  |     includes, ignores = args_includes_ignores(args) | 
					
						
							| 
									
										
										
										
											2020-02-12 22:30:44 +01:00
										 |  |  |     dependables = @use_runtime_dependencies ? f.runtime_dependencies : f.deps | 
					
						
							|  |  |  |     deps = reject_ignores(dependables, ignores, includes) | 
					
						
							| 
									
										
										
										
											2019-12-27 17:35:18 -05:00
										 |  |  |     reqs = reject_ignores(f.requirements, ignores, includes) | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     dependables = reqs + deps | 
					
						
							| 
									
										
										
										
											2019-12-27 17:35:18 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     max = dependables.length - 1
 | 
					
						
							|  |  |  |     @dep_stack.push f.name | 
					
						
							|  |  |  |     dependables.each_with_index do |dep, i| | 
					
						
							| 
									
										
										
										
											2019-01-23 08:34:24 +05:30
										 |  |  |       next if !args.include_requirements? && dep.is_a?(Requirement) | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       tree_lines = if i == max | 
					
						
							| 
									
										
										
										
											2016-12-20 03:59:15 -05:00
										 |  |  |         "└──" | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         "├──" | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |       display_s = "#{tree_lines} #{dep_display_name(dep, args: args)}" | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       is_circular = @dep_stack.include?(dep.name) | 
					
						
							|  |  |  |       display_s = "#{display_s} (CIRCULAR DEPENDENCY)" if is_circular | 
					
						
							|  |  |  |       puts "#{prefix}#{display_s}" | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       next if !recursive || is_circular | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |       prefix_addition = if i == max | 
					
						
							|  |  |  |         "    " | 
					
						
							| 
									
										
										
										
											2016-12-20 03:59:15 -05:00
										 |  |  |       else | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |         "│   " | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-31 19:09:53 +02:00
										 |  |  |       if dep.is_a? Dependency | 
					
						
							|  |  |  |         recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true, args: args) | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-06-09 12:59:42 -05:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-03-26 10:55:29 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-03 00:41:51 -04:00
										 |  |  |     @dep_stack.pop | 
					
						
							| 
									
										
										
										
											2013-06-09 12:59:42 -05:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  | end |