Add time/date filtering support.
This commit is contained in:
parent
af321e9024
commit
53a9d33647
1 changed files with 27 additions and 3 deletions
|
@ -168,6 +168,10 @@ class GitExtractor
|
||||||
@config = {
|
@config = {
|
||||||
:author_filter_enable => false,
|
:author_filter_enable => false,
|
||||||
:author_filter => ".*?",
|
:author_filter => ".*?",
|
||||||
|
|
||||||
|
:date_filter_enable => false,
|
||||||
|
:date_filter => ".*?",
|
||||||
|
|
||||||
:verbose => false
|
:verbose => false
|
||||||
}
|
}
|
||||||
@rangelist = nil
|
@rangelist = nil
|
||||||
|
@ -186,8 +190,21 @@ class GitExtractor
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("-a","--author AUTHOR", "Only keep commits for AUTHOR") do |author|
|
opts.on("-d","--date DATE", "Keep only commits since DATE") do |date|
|
||||||
puts "set commit author to #{author}"
|
puts "set date filter to #{date}"
|
||||||
|
@config[:date_filter] = DateTime.parse(date);
|
||||||
|
@config[:date_filter_enable] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("-t","--time TIME", "Keep only commits on last TIME datys") do |time|
|
||||||
|
puts "set time filter to latest #{time} days"
|
||||||
|
@config[:date_filter] = DateTime.now - time.to_f;
|
||||||
|
puts "set date filter to date = #{@config[:date_filter]}"
|
||||||
|
@config[:date_filter_enable] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("-a","--author AUTHOR", "Keep only commits by AUTHOR") do |author|
|
||||||
|
puts "set author filter to #{author}"
|
||||||
@config[:author_filter] = author
|
@config[:author_filter] = author
|
||||||
@config[:author_filter_enable] = true
|
@config[:author_filter_enable] = true
|
||||||
end
|
end
|
||||||
|
@ -224,7 +241,8 @@ class GitExtractor
|
||||||
unless commit.nil? then
|
unless commit.nil? then
|
||||||
commit.author = $1
|
commit.author = $1
|
||||||
|
|
||||||
if not commit.author =~ /#{@config[:author_filter]}/ then
|
if @config[:author_filter_enable] and
|
||||||
|
(not commit.author =~ /#{@config[:author_filter]}/) then
|
||||||
commit = nil
|
commit = nil
|
||||||
# reject
|
# reject
|
||||||
end
|
end
|
||||||
|
@ -233,6 +251,12 @@ class GitExtractor
|
||||||
when /^Date:\s*(.*?)\s*$/ then
|
when /^Date:\s*(.*?)\s*$/ then
|
||||||
unless commit.nil? then
|
unless commit.nil? then
|
||||||
commit.date = $1
|
commit.date = $1
|
||||||
|
|
||||||
|
if @config[:date_filter_enable] and
|
||||||
|
(DateTime.parse(commit.date) < @config[:date_filter]) then
|
||||||
|
commit = nil
|
||||||
|
# reject
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
when /^\s*$/ then
|
when /^\s*$/ then
|
||||||
|
|
Loading…
Reference in a new issue