summaryrefslogtreecommitdiffstats
path: root/lib/git/log.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-08 11:22:46 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-08 11:22:46 -0800
commitb18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b (patch)
tree718f1b6451f5a9dd9b8cb844fa3d3e9f32400d50 /lib/git/log.rb
parent169381bbce998807c119f291d69b8ae1d8fb5785 (diff)
downloadthird_party-ruby-git-b18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b.tar.gz
third_party-ruby-git-b18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b.tar.xz
third_party-ruby-git-b18bca3b853dee6a7bc86f09921aa3b1ee3f3d7b.zip
added log functions
Diffstat (limited to 'lib/git/log.rb')
-rw-r--r--lib/git/log.rb35
1 files changed, 35 insertions, 0 deletions
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