/
committers.rake
60 lines (53 loc) · 1.47 KB
/
committers.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# shell command for quarterly list of committers
def quarterly_committers(start_month, year=Time.now.year)
"git log --since='#{start_month}/1/#{year}' --until='#{start_month + 2}/31/#{year}' | git shortlog -n -s -e"
end
def future?(start_month, year=Time.now.year)
require "date"
if Date.parse("#{start_month}/1/#{year}") > Date.today
puts
puts "ERROR: That's the future!"
puts
true
elsif year < Time.now.year
false
elsif Date.parse("#{start_month + 2}/28/#{year}") > Date.today
puts
puts "WARNING: That's the current quarter."
puts
end
end
namespace :committers do
desc "Prints list of committers from first calendar quarter of this year"
task :q1 do
unless future?(1)
sh quarterly_committers(1)
end
end
desc "Prints list of committers from second calendar quarter of this year"
task :q2 do
unless future?(4)
sh quarterly_committers(4)
end
end
desc "Prints list of committers from third calendar quarter of this year"
task :q3 do
unless future?(7)
sh quarterly_committers(7)
end
end
desc "Prints list of committers from fourth calendar quarter of this year"
task :q4 do
unless future?(10)
sh quarterly_committers(10)
end
end
namespace :q4 do
desc "Prints list of committers from fourth calendar quarter of LAST year"
task :last_year do
unless future?(10, Time.now.year - 1)
sh quarterly_committers(10, Time.now.year - 1)
end
end
end
end