Sha256: 8ac591192641a9b7233e98480c21d272b4a6af27921a899af122faa15f209bf0
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'wlog/domain/git_commit' module Wlog # Parses git text from a `git log` command invocation # @author Simon Symeonidis class GitCommitParser # @param log_s is the string obtained from running a `git log` command # @return a list of GitCommit objects def self.parse(log_s) cur = nil inmessage = false gitlogs = [] log_s.lines.each do |line| case line when /^commit/i inmessage = false gitlogs.push cur if cur cur = GitCommit.new cur.commit = line.split[1].strip when /^author/i next unless cur cur.author = line.split[1].strip when /^date/i, /^\n$/ next else next unless cur if inmessage cur.message.concat(line) cur.message.strip! else cur.shortlog = line cur.shortlog.strip! inmessage = true end end end # if commits have no hash, discard them gitlogs.reject! { |e| e.commit == "" } gitlogs.push cur if cur gitlogs end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wlog-1.2.2 | lib/wlog/tech/git_commit_parser.rb |