Skip to content

Commit

Permalink
Merge pull request #52 from apainintheneck/fix-service-diff-command
Browse files Browse the repository at this point in the history
Fix service-diff command
  • Loading branch information
apainintheneck authored Oct 12, 2024
2 parents 117e8b4 + b954d44 commit 3c024a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ Warning: This command runs git commands on the main brew repo. To be safe avoid
running other brew commands simultaneously.
--formula Run the diff on only one formula.
--tap Run the diff on only one tap.
--word-diff Show word diff instead of default line diff.
--stat Shows condensed output based on git
diff --stat
Expand Down
6 changes: 1 addition & 5 deletions cmd/service-diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ class ServiceDiff < AbstractCommand
EOS

flag "--formula=", description: "Run the diff on only one formula."
flag "--tap=", description: "Run the diff on only one tap."
switch "--word-diff", description: "Show word diff instead of default line diff."
switch "--stat", description: "Shows condensed output based on `git diff --stat`"

conflicts "--tap=", "--formula="
conflicts "--word-diff", "--stat"
end

Expand All @@ -32,9 +30,7 @@ def run
odie "Script #{script_path} doesn't exist!" unless File.exist?(script_path)

script_args =
if args.tap
["tap", args.tap]
elsif args.formula
if args.formula
["formula", args.formula]
else
["all"]
Expand Down
9 changes: 4 additions & 5 deletions lib/diff-scripts/service_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
# Expects:
# 1. Command type from VALID_COMMAND_TYPES
# 2. Command arg
# - for command type `tap` it should be the name of a tap
# - for command type `formula` it should be the name of a formula
# - for command type `all` it is NOT necessary
COMMAND_TYPE, COMMAND_ARG, *extra = ARGV

VALID_COMMAND_TYPES = %w[all tap formula].freeze
VALID_COMMAND_TYPES = %w[all formula].freeze

if VALID_COMMAND_TYPES.exclude?(COMMAND_TYPE)
odie "Unknown command type `#{COMMAND_TYPE}`!"
Expand All @@ -29,9 +28,9 @@
FORMULAE =
case COMMAND_TYPE
when "all"
Formula.all(eval_all: true)
when "tap"
Tap.fetch(COMMAND_ARG).formula_files.map(&Formulary.method(:factory))
CoreTap.instance.formula_names.map do |name|
Formulary.factory(name)
end
when "formula"
[Formulary.factory(COMMAND_ARG)]
end
Expand Down

0 comments on commit 3c024a5

Please sign in to comment.