class GitCommitLogParser

this is not namespaced under Solano because we want to eventually move this out into another gem

Attributes

commit_log[RW]

Public Class Methods

new(commit_log) click to toggle source

15e8cbd88d68d210953d51c28e26c6b9944a313b ignore .ruby-version for rvm Bob Smith bob@example.com 1367556311 Fred Smith fred@example.com 1367556311

# File lib/solano/scm/git_log_parser.rb, line 20
def initialize(commit_log)
  @commit_log = commit_log
end

Public Instance Methods

commits() click to toggle source

Returns a list of commits in the following format [{

"id" =>        "15e8cbd88d68d210953d51c28e26c6b9944a313b",
"author" =>    {"name"=>"Bob Smith", "email"=>"bob@example.com"},
"committer" => {"name"=>"Fred Smith", "email"=>"fred@example.com"},
"summary"   => "ignore .ruby-version for rvm",
"date"      => 1380603292

}]

# File lib/solano/scm/git_log_parser.rb, line 33
def commits
  record = []
  commits = []
  commit_log.lines.each do |line|
    line.strip!
    line.sanitize!
    if line.empty?
      c = parse_commit(record)
      commits.push(c)
      record = []
    else
      record.push(line)
    end
  end

  commits
end

Private Instance Methods

build_commit(sha, author, committer, summary, date) click to toggle source
# File lib/solano/scm/git_log_parser.rb, line 64
def build_commit(sha, author, committer, summary, date)
  {"id" => sha, "author" => author, "committer" => committer, "summary" => summary, "date" => date}
end
build_user(name, email) click to toggle source
# File lib/solano/scm/git_log_parser.rb, line 60
def build_user(name, email)
  {"name" => name, "email" => email}
end
parse_commit(record) click to toggle source
# File lib/solano/scm/git_log_parser.rb, line 53
def parse_commit(record)
  time = record[4].to_i
  author = build_user(record[2], record[3])
  committer = build_user(record[5], record[6])
  build_commit(record[0], author, committer, record[1], time)
end