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.



7
8
9
10
11
# File 'lib/git/log.rb', line 7

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

Instance Method Details

#[](index)



100
101
102
103
# File 'lib/git/log.rb', line 100

def [](index)
  check_log
  @commits[index] rescue nil
end

#all



13
14
15
16
17
# File 'lib/git/log.rb', line 13

def all
  dirty_log
  @all = true
  self
end

#author(regex)



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

def author(regex)
  dirty_log
  @author = regex
  return self
end

#between(sha1, sha2 = nil)



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

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

#cherry



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

def cherry
  dirty_log
  @cherry = true
  return self
end

#each(&block)



85
86
87
88
# File 'lib/git/log.rb', line 85

def each(&block)
  check_log
  @commits.each(&block)
end

#first



90
91
92
93
# File 'lib/git/log.rb', line 90

def first
  check_log
  @commits.first rescue nil
end

#grep(regex)



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

def grep(regex)
  dirty_log
  @grep = regex
  return self
end

#last



95
96
97
98
# File 'lib/git/log.rb', line 95

def last
  check_log
  @commits.last rescue nil
end

#object(objectish)



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

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

#path(path)



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

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

#since(date)



49
50
51
52
53
# File 'lib/git/log.rb', line 49

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

#size

forces git log to run



80
81
82
83
# File 'lib/git/log.rb', line 80

def size
  check_log
  @commits.size rescue nil
end

#skip(num)



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

def skip(num)
  dirty_log
  @skip = num
  return self
end

#to_s



73
74
75
# File 'lib/git/log.rb', line 73

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

#until(date)



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

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