Class: Git::Log
Overview
Return the last n commits that match the specified criteria
Defined Under Namespace
Classes: Result
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)
-
#execute ⇒ Git::Log::Result
Executes the git log command and returns an immutable result object.
- #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
91 92 93 94 95 |
# File 'lib/git/log.rb', line 91 def initialize(base, max_count = 30) dirty_log @base = base max_count(max_count) end |
Instance Method Details
#[](index)
243 244 245 246 247 |
# File 'lib/git/log.rb', line 243 def [](index) deprecate_method(__method__) 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.
145 146 147 148 149 |
# File 'lib/git/log.rb', line 145 def all dirty_log @all = true self end |
#author(regex)
157 158 159 160 161 |
# File 'lib/git/log.rb', line 157 def (regex) dirty_log = regex self end |
#between(sha1, sha2 = nil)
193 194 195 196 197 |
# File 'lib/git/log.rb', line 193 def between(sha1, sha2 = nil) dirty_log @between = [sha1, sha2] self end |
#cherry
199 200 201 202 203 |
# File 'lib/git/log.rb', line 199 def cherry dirty_log @cherry = true self end |
#each(&block)
225 226 227 228 229 |
# File 'lib/git/log.rb', line 225 def each(&block) deprecate_method(__method__) check_log @commits.each(&block) end |
#execute ⇒ Git::Log::Result
Executes the git log command and returns an immutable result object.
This is the preferred way to get log data. It separates the query building from the execution, making the API more predictable.
111 112 113 114 |
# File 'lib/git/log.rb', line 111 def execute run_log Result.new(@commits) end |
#first
231 232 233 234 235 |
# File 'lib/git/log.rb', line 231 def first deprecate_method(__method__) check_log @commits.first rescue nil end |
#grep(regex)
163 164 165 166 167 |
# File 'lib/git/log.rb', line 163 def grep(regex) dirty_log @grep = regex self end |
#last
237 238 239 240 241 |
# File 'lib/git/log.rb', line 237 def last deprecate_method(__method__) check_log @commits.last rescue nil end |
#max_count(num_or_all) ⇒ self
The maximum number of commits to return
127 128 129 130 131 |
# File 'lib/git/log.rb', line 127 def max_count(num_or_all) dirty_log @max_count = (num_or_all == :all) ? nil : num_or_all self end |
#merges
205 206 207 208 209 |
# File 'lib/git/log.rb', line 205 def merges dirty_log @merges = true self end |
#object(objectish)
151 152 153 154 155 |
# File 'lib/git/log.rb', line 151 def object(objectish) dirty_log @object = objectish self end |
#path(path)
169 170 171 172 173 |
# File 'lib/git/log.rb', line 169 def path(path) dirty_log @path = path self end |
#since(date)
181 182 183 184 185 |
# File 'lib/git/log.rb', line 181 def since(date) dirty_log @since = date self end |
#size
forces git log to run
219 220 221 222 223 |
# File 'lib/git/log.rb', line 219 def size deprecate_method(__method__) check_log @commits.size rescue nil end |
#skip(num)
175 176 177 178 179 |
# File 'lib/git/log.rb', line 175 def skip(num) dirty_log @skip = num self end |
#to_s
211 212 213 214 215 |
# File 'lib/git/log.rb', line 211 def to_s deprecate_method(__method__) check_log @commits.map { |c| c.to_s }.join("\n") end |
#until(date)
187 188 189 190 191 |
# File 'lib/git/log.rb', line 187 def until(date) dirty_log @until = date self end |