2016-07-28 00:04:57 -04:00
|
|
|
module Gitlab
|
|
|
|
class ChangesList
|
|
|
|
include Enumerable
|
|
|
|
|
|
|
|
attr_reader :raw_changes
|
|
|
|
|
|
|
|
def initialize(changes)
|
2017-02-22 12:25:50 -05:00
|
|
|
@raw_changes = changes.is_a?(String) ? changes.lines : changes
|
2016-07-28 00:04:57 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def each(&block)
|
|
|
|
changes.each(&block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def changes
|
|
|
|
@changes ||= begin
|
|
|
|
@raw_changes.map do |change|
|
|
|
|
next if change.blank?
|
2017-11-14 04:02:39 -05:00
|
|
|
|
2016-07-28 00:04:57 -04:00
|
|
|
oldrev, newrev, ref = change.strip.split(' ')
|
|
|
|
{ oldrev: oldrev, newrev: newrev, ref: ref }
|
|
|
|
end.compact
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|