From 8e5a5672fbfc82dec4eb6108346d13302159aec0 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 28 Jul 2022 11:20:04 +0100 Subject: [PATCH] dev-cmd/contributions: Better shell argument handling, plus stop piping to `grep` --- Library/Homebrew/dev-cmd/contributions.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/dev-cmd/contributions.rb b/Library/Homebrew/dev-cmd/contributions.rb index 22aa7b307b..d83a6e78ca 100755 --- a/Library/Homebrew/dev-cmd/contributions.rb +++ b/Library/Homebrew/dev-cmd/contributions.rb @@ -80,21 +80,20 @@ module Homebrew sig { params(repo_path: Pathname, args: Homebrew::CLI::Args).returns(Integer) } def git_log_author_cmd(repo_path, args) - cmd = "git -C #{repo_path} log --oneline --author=#{args.named.first}" - cmd += " --before=#{args[:to]}" if args[:to] - cmd += " --after=#{args[:from]}" if args[:from] + cmd = ["git", "-C", repo_path, "log", "--oneline", "--author=#{args.named.first}"] + cmd << "--before=#{args[:to]}" if args[:to] + cmd << "--after=#{args[:from]}" if args[:from] - Utils.safe_popen_read(cmd).lines.count + Utils.safe_popen_read(*cmd).lines.count end sig { params(repo_path: Pathname, args: Homebrew::CLI::Args).returns(Integer) } def git_log_coauthor_cmd(repo_path, args) - cmd = "git -C #{repo_path} log --oneline" - cmd += " --format='%(trailers:key=Co-authored-by:)'" - cmd += " --before=#{args[:to]}" if args[:to] - cmd += " --after=#{args[:from]}" if args[:from] - cmd += " | grep #{args.named.first}" + cmd = ["git", "-C", repo_path, "log", "--oneline"] + cmd << "--format='%(trailers:key=Co-authored-by:)'" + cmd << "--before=#{args[:to]}" if args[:to] + cmd << "--after=#{args[:from]}" if args[:from] - Utils.safe_popen_read(cmd).lines.count + Utils.safe_popen_read(*cmd).lines.select { |l| l.include?(args.named.first) }.length end end