Method: VCLog::Adapters::Svn#extract_changes

Defined in:
lib/vclog/adapters/svn.rb

#extract_changesObject

Extract changes.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vclog/adapters/svn.rb', line 26

def extract_changes
  log = []

  xml = `svn log -v --xml`.strip

  commits = XmlSimple.xml_in(xml, {'KeyAttr' => 'rev'})
  commits = commits['logentry']

  commits.each do |com|
    rev  = com['revision']
    msg  = [com['msg']].flatten.compact.join('').strip
    who  = [com['author']].flatten.compact.join('').strip
    date = [com['date']].flatten.compact.join('').strip

    files = com['paths'].map{ |h| h['path'].map{ |y| y['content'] } }.flatten

    next if msg.empty?
    next if msg == "*** empty log message ***"

    date = Time.parse(date)

    log << Change.new(:id=>rev, :date=>date, :who=>who, :msg=>msg, :files=>files)
  end

  log
end