From b18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Thu, 8 Nov 2007 11:22:46 -0800 Subject: added log functions --- lib/git/log.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/git/log.rb (limited to 'lib/git/log.rb') diff --git a/lib/git/log.rb b/lib/git/log.rb new file mode 100644 index 0000000..fab605e --- /dev/null +++ b/lib/git/log.rb @@ -0,0 +1,35 @@ +module Git + + # object that holds the last X commits on given branch + class Log + include Enumerable + + @base = nil + @commits = nil + + def initialize(base, count = 30) + @base = base + @commits = @base.lib.log_shas(count) + end + + def size + @commits.size + end + + def each + @commits.each do |c| + yield c + end + end + + def first + @commits.first + end + + def to_s + self.map { |c| c.sha }.join("\n") + end + + end + +end \ No newline at end of file -- cgit