Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add log count option to log/shortlog.
- Loading branch information
Glenn Hutchings
committed
Jun 4, 2010
1 parent
d94f156
commit 03a6712
Showing
2 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Add optional count to log/shortlog commands. | ||
|
||
diff --git a/lib/operator.rb b/lib/operator.rb | ||
--- a/lib/operator.rb | ||
+++ b/lib/operator.rb | ||
@@ -518,8 +518,11 @@ EOS | ||
puts(todo_list_for(issues) || "No matching issues.") | ||
end | ||
|
||
- operation :log, "Show recent activity" | ||
- def log project, config | ||
+ operation :log, "Show recent activity", :maybe_count do | ||
+ opt :count, "Show specified number of log entries", :default => 0 | ||
+ end | ||
+ def log project, config, opts, count | ||
+ count = count.to_i | ||
project.issues.map { |i| i.log_events.map { |e| [e, i] } }. | ||
flatten_one_level.sort_by { |e| e.first.first }.reverse. | ||
each do |(date, author, what, comment), i| | ||
@@ -531,12 +534,17 @@ issue : [#{i.name}] #{i.title} | ||
#{what} | ||
#{comment.gsub(/^/, " > ") unless comment =~ /^\A\s*\z/} | ||
EOS | ||
- puts unless comment.blank? | ||
+ puts unless comment.blank? | ||
+ count -= 1 | ||
+ break if count == 0 | ||
end | ||
end | ||
|
||
- operation :shortlog, "Show recent activity (short form)" | ||
- def shortlog project, config | ||
+ operation :shortlog, "Show recent activity (short form)", :maybe_count do | ||
+ opt :count, "Show specified number of log entries", :default => 0 | ||
+ end | ||
+ def shortlog project, config, opts, count | ||
+ count = count.to_i | ||
project.issues.map { |i| i.log_events.map { |e| [e, i] } }. | ||
flatten_one_level.sort_by { |e| e.first.first }.reverse. | ||
each do |(date, author, what, comment), i| | ||
@@ -547,7 +555,9 @@ EOS | ||
end[0..15] | ||
printf "%10s | %10s | %16s | %s\n", date.ago, i.name, shortauthor, | ||
what | ||
- end | ||
+ count -= 1 | ||
+ break if count == 0 | ||
+ end | ||
end | ||
|
||
operation :archive, "Archive a release", :release, :maybe_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters