
On Thu, Aug 20, 2020 at 08:21:18PM +0800, Bai Jing wrote:
On Thu, Aug 20, 2020 at 04:58:11PM +0800, Wu Fengguang wrote:
两段unless File.exist?代码有重复, 一段是不是就够了?
%x => system 更好些
+unless File.exist?("#{ENV['HOME']}/.am") + repos.each_key do |repo| + %x(mkdir -p ~/.am && cd ~/.am && git clone file:///c/#{repo}.git) + end +end + count_by_name.sort_by { |k, _v| k }
repos.each do |repo, files| + unless File.exist?("#{ENV['HOME']}/.am/#{repo}") + %x(cd ~/.am/ && git clone file:///c/#{repo}.git) + end + %x(git -C ~/.am/#{repo} pull --rebase) %x(cd ~/.am/#{repo} && git shortlog -ens --no-merges --since "#{days} days ago" -- #{files}).each_line do |line|
command : system("\"cd ~/.am/#{repo} && git shortlog -ens --no-merges --since '#{days} days ago' -- #{files}\"")
是不是 \" 多余了
I tried use system to replace "%x", but this command show below error.
error : sh: cd ~/.am/ameba && git shortlog -ens --no-merges --since '1 days ago' -- : No such file or directory