module Idonethis::UseCases module Git class << self def apply(credential, args={}) log = args[:log] || fail("You need to supply :log adapter") dir = File.expand_path("..") all_dirs = Dir.entries(dir).reject{|it| ["..", "."].include?(it) }.select{|it| File.directory?(File.join(dir, it))}.map{|it| File.join(dir, it)} dirs_that_have_changed_today = all_dirs.select{|it| today?(File.mtime(it)) } puts "Scanning dir <#{dir}>, which has <#{dirs_that_have_changed_today.size}> repositories that have changed\n\n" dirs_that_have_changed_today.each do |dir| summary = commit_summary(dir) puts %Q{#{Pathname.new(dir).basename} (#{summary.size}):\n-- #{summary.join("\n-- ")}"} end puts "" end def today?(time) now = Time.now time.year == now.year && time.month == now.month && time.day == now.day end def commit_summary(dir) require 'git' git = ::Git.open(dir) git.log.since('1am').take(10).map{|it| %Q{[#{it.date.strftime("%H:%M")}] #{it.message}}} end end end end