Welcome to mirror list, hosted at ThFree Co, Russian Federation.

changes_list.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb75a78a97897bebbb4b9a5dcbd90b359e5f5759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Gitlab
  class ChangesList
    include Enumerable

    attr_reader :raw_changes

    def initialize(changes)
      @raw_changes = changes.is_a?(String) ? changes.lines : changes
    end

    def each(&block)
      changes.each(&block)
    end

    def changes
      @changes ||= begin
        @raw_changes.map do |change|
          next if change.blank?

          oldrev, newrev, ref = change.strip.split(' ')
          { oldrev: oldrev, newrev: newrev, ref: ref }
        end.compact
      end
    end
  end
end