debian-mirror-gitlab/lib/gitlab/string_regex_marker.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
448 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Gitlab
class StringRegexMarker < StringRangeMarker
def mark(regex, group: 0, &block)
2018-03-27 19:54:05 +05:30
ranges = []
2021-09-30 23:02:18 +05:30
offset = 0
2017-09-10 17:25:29 +05:30
2021-09-30 23:02:18 +05:30
while match = regex.match(raw_line[offset..])
begin_index = match.begin(group) + offset
end_index = match.end(group) + offset
2017-09-10 17:25:29 +05:30
2018-03-27 19:54:05 +05:30
ranges << (begin_index..(end_index - 1))
2021-09-30 23:02:18 +05:30
offset = end_index
2018-03-27 19:54:05 +05:30
end
super(ranges, &block)
2017-09-10 17:25:29 +05:30
end
end
end