Sha256: 9ea7b51a82083c8119d978100f381f8f4626c888de5c6fa4b277c56d86630e01
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
module Idonethis::UseCases module Git class << self def apply(_, args={}) log = args[:log] || fail("You need to supply :log adapter") git = args[:git] || fail("You need to supply :git adapter") view = args[:view] || fail("You need to supply :view adapter") fs = args[:fs] || fail("You need to supply :fs adapter") since = args[:since] || 'today' log.call args opts = args[:opts] || [] dir = opts.any? ? File.expand_path(opts.first) : File.expand_path(".") dirs = dir if dir == FileUtils.pwd view.call "Scanning the current directory <#{dir}>\n\n" else dirs = fs.modified_today?(dir) view.call "Scanning dir <#{dir}>, which has <#{dirs_that_have_changed_today.size}> repositories that have changed today\n\n" end view.call summarise(git, view, since, *dirs) view.call "" end def summarise(git, view, since, *dirs) dirs.map do |dir| commits = git.commits(dir, since).map{|it| %Q{[#{date_from(it)}] #{it.message}}} %Q{#{Pathname.new(dir).basename} (#{commits.size}):\n\n-- #{commits.join("\n-- ")}} end.join "\n\n" end def date_from(commit) return commit.date.strftime("%d %b, %H:%M") unless today?(commit.date, Time.now) commit.date.strftime("%H:%M") end def today?(time, now) time.year == now.year && time.month == now.month && time.day == now.day end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
idonethis-cli-0.13.1 | lib/idonethis/use_cases/git.rb |
idonethis-cli-0.13.0 | lib/idonethis/use_cases/git.rb |