Class: Git::Log

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/git/log.rb

Overview

object that holds the last X commits on given branch

Instance Method Summary collapse

Constructor Details

#initialize(base, count = 30) ⇒ Log

Returns a new instance of Log.



18
19
20
21
22
# File 'lib/git/log.rb', line 18

def initialize(base, count = 30)
  dirty_log
  @base = base
  @count = count
end

Instance Method Details

#between(sha1, sha2 = nil) ⇒ Object



42
43
44
45
46
# File 'lib/git/log.rb', line 42

def between(sha1, sha2 = nil)
  dirty_log
  @between = [sha1, sha2]
  return self
end

#eachObject



60
61
62
63
64
65
# File 'lib/git/log.rb', line 60

def each
  check_log
  @commits.each do |c|
    yield c
  end
end

#firstObject



67
68
69
70
# File 'lib/git/log.rb', line 67

def first
  check_log
  @commits.first rescue nil
end

#object(objectish) ⇒ Object



24
25
26
27
28
# File 'lib/git/log.rb', line 24

def object(objectish)
  dirty_log
  @object = objectish
  return self
end

#path(path) ⇒ Object



30
31
32
33
34
# File 'lib/git/log.rb', line 30

def path(path)
  dirty_log
  @path = path
  return self
end

#since(date) ⇒ Object



36
37
38
39
40
# File 'lib/git/log.rb', line 36

def since(date)
  dirty_log
  @since = date
  return self
end

#sizeObject

forces git log to run



55
56
57
58
# File 'lib/git/log.rb', line 55

def size
  check_log
  @commits.size rescue nil
end

#to_sObject



48
49
50
# File 'lib/git/log.rb', line 48

def to_s
  self.map { |c| c.to_s }.join("\n")
end