diff options
Diffstat (limited to 'lib/git/log.rb')
-rw-r--r-- | lib/git/log.rb | 35 |
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 |