class Git::Log

object that holds the last X commits on given branch

def author(regex)

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

def between(sha1, sha2 = nil)

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

def check_log

def check_log
  if @dirty_flag
    run_log
    @dirty_flag = false
  end
end

def dirty_log

def dirty_log
  @dirty_flag = true
end

def each(&block)

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

def first

def first
  check_log
  @commits.first rescue nil
end

def grep(regex)

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

def initialize(base, count = 30)

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

def object(objectish)

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

def path(path)

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

def run_log

actually run the 'git log' command
def run_log      
  log = @base.lib.full_log_commits(:count => @count, :object => @object, 
                              :path_limiter => @path, :since => @since, 
                              :author => @author, :grep => @grep, :skip => @skip,
                              :until => @until, :between => @between)
  @commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
end

def since(date)

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

def size

def size
  check_log
  @commits.size rescue nil
end

def skip(num)

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

def to_s

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

def until(date)

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