35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/weekly_commits/cli.rb', line 35
def weekly_commits
relative_week = options[:week]
beg_week = relative_week.week.ago.beginning_of_week
5.times do |day_count|
date = beg_week + day_count.days
week_title = date.strftime('%a, %e %b %Y')
git_date_format = date.strftime('%Y-%m-%e')
committer = options[:show_author] ? ' (%cn)'.magenta : ''
git_log_command = "git --no-pager log --after='#{git_date_format} 00:00' --before='#{git_date_format} 23:59' --pretty=format:'%s#{committer}'"
git_log_command += ' --no-merges' if options[:no_merge]
commits = `#{git_log_command}`
commits = commits.lines.reverse if options[:sort].casecmp('asc').zero?
puts week_title.yellow
puts commits
puts
end
end
|