Class: Blammo::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/blammo/git.rb

Constant Summary collapse

CHUNK_SIZE =
10

Class Method Summary collapse

Class Method Details

.each_commit(path, since = nil, &block) ⇒ Object

Yield each commit in the given repository since the given SHA.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/blammo/git.rb', line 8

def self.each_commit(path, since = nil, &block)
  git   = ::Git.open(path)
  log   = ::Git::Log.new(git, CHUNK_SIZE)
  chunk = 0

  log.between(since, "head") if since

  begin
    log.skip(chunk * CHUNK_SIZE)
    log.each {|commit| block.call(commit.sha, commit.message.strip)}
    chunk += 1
  end until log.size == 0
end