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
12
13
14
15
16
17
18
19
20
21
# File 'lib/git/log.rb', line 7

def initialize(base, count = 30)
  dirty_log
  @base = base
  @count = count
 
  @commits = nil
  @author = nil
  @grep = nil
  @object = nil
  @path = nil
  @since = nil
  @skip = nil
  @until = nil
  @between = nil
end

Instance Method Details

#[](index) ⇒ Object



98
99
100
101
# File 'lib/git/log.rb', line 98

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

#author(regex) ⇒ Object



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

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

#between(sha1, sha2 = nil) ⇒ Object



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

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

#each(&block) ⇒ Object



83
84
85
86
# File 'lib/git/log.rb', line 83

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

#firstObject



88
89
90
91
# File 'lib/git/log.rb', line 88

def first
  check_log
  @commits.first rescue nil
end

#grep(regex) ⇒ Object



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

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

#lastObject



93
94
95
96
# File 'lib/git/log.rb', line 93

def last
  check_log
  @commits.last rescue nil
end

#object(objectish) ⇒ Object



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

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

#path(path) ⇒ Object



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

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

#since(date) ⇒ Object



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

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

#sizeObject

forces git log to run



78
79
80
81
# File 'lib/git/log.rb', line 78

def size
  check_log
  @commits.size rescue nil
end

#skip(num) ⇒ Object



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

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

#to_sObject



71
72
73
# File 'lib/git/log.rb', line 71

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

#until(date) ⇒ Object



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

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