Class: Git::Log
Overview
Return the last n commits that match the specified criteria
Instance Method Summary collapse
- #[](index)
-
#all ⇒ self
Adds the --all flag to the git log command.
- #author(regex)
- #between(sha1, sha2 = nil)
- #cherry
- #each(&block)
- #first
- #grep(regex)
-
#initialize(base, max_count = 30) ⇒ Log
constructor
Create a new Git::Log object.
- #last
-
#max_count(num_or_all) ⇒ self
The maximum number of commits to return.
- #merges
- #object(objectish)
- #path(path)
- #since(date)
-
#size
forces git log to run.
- #skip(num)
- #to_s
- #until(date)
Constructor Details
#initialize(base, max_count = 30) ⇒ Log
Create a new Git::Log object
41 42 43 44 45 |
# File 'lib/git/log.rb', line 41 def initialize(base, max_count = 30) dirty_log @base = base max_count(max_count) end |
Instance Method Details
#[](index)
168 169 170 171 |
# File 'lib/git/log.rb', line 168 def [](index) check_log @commits[index] rescue nil end |
#all ⇒ self
Adds the --all flag to the git log command
This asks for the logs of all refs (basically all commits reachable by HEAD, branches, and tags). This does not control the maximum number of commits returned. To control how many commits are returned, call #max_count.
76 77 78 79 80 |
# File 'lib/git/log.rb', line 76 def all dirty_log @all = true self end |
#author(regex)
88 89 90 91 92 |
# File 'lib/git/log.rb', line 88 def (regex) dirty_log = regex return self end |
#between(sha1, sha2 = nil)
124 125 126 127 128 |
# File 'lib/git/log.rb', line 124 def between(sha1, sha2 = nil) dirty_log @between = [sha1, sha2] return self end |
#cherry
130 131 132 133 134 |
# File 'lib/git/log.rb', line 130 def cherry dirty_log @cherry = true return self end |
#each(&block)
153 154 155 156 |
# File 'lib/git/log.rb', line 153 def each(&block) check_log @commits.each(&block) end |
#first
158 159 160 161 |
# File 'lib/git/log.rb', line 158 def first check_log @commits.first rescue nil end |
#grep(regex)
94 95 96 97 98 |
# File 'lib/git/log.rb', line 94 def grep(regex) dirty_log @grep = regex return self end |
#last
163 164 165 166 |
# File 'lib/git/log.rb', line 163 def last check_log @commits.last rescue nil end |
#max_count(num_or_all) ⇒ self
The maximum number of commits to return
58 59 60 61 62 |
# File 'lib/git/log.rb', line 58 def max_count(num_or_all) dirty_log @max_count = (num_or_all == :all) ? nil : num_or_all self end |
#merges
136 137 138 139 140 |
# File 'lib/git/log.rb', line 136 def merges dirty_log @merges = true return self end |
#object(objectish)
82 83 84 85 86 |
# File 'lib/git/log.rb', line 82 def object(objectish) dirty_log @object = objectish return self end |
#path(path)
100 101 102 103 104 |
# File 'lib/git/log.rb', line 100 def path(path) dirty_log @path = path return self end |
#since(date)
112 113 114 115 116 |
# File 'lib/git/log.rb', line 112 def since(date) dirty_log @since = date return self end |
#size
forces git log to run
148 149 150 151 |
# File 'lib/git/log.rb', line 148 def size check_log @commits.size rescue nil end |
#skip(num)
106 107 108 109 110 |
# File 'lib/git/log.rb', line 106 def skip(num) dirty_log @skip = num return self end |
#to_s
142 143 144 |
# File 'lib/git/log.rb', line 142 def to_s self.map { |c| c.to_s }.join("\n") end |
#until(date)
118 119 120 121 122 |
# File 'lib/git/log.rb', line 118 def until(date) dirty_log @until = date return self end |