class Dependabot::PullRequestCreator::MessageBuilder::IssueLinker
Constants
- ISSUE_LINK_REGEXS
- REPO_REGEX
- TAG_REGEX
Attributes
source_url[R]
Public Class Methods
new(source_url:)
click to toggle source
# File lib/dependabot/pull_request_creator/message_builder/issue_linker.rb, line 22 def initialize(source_url:) @source_url = source_url end
Public Instance Methods
link_issues(text:)
click to toggle source
# File lib/dependabot/pull_request_creator/message_builder/issue_linker.rb, line 26 def link_issues(text:) # Loop through each of the issue link regexes, replacing any instances # of them with an absolute link that uses the source URL ISSUE_LINK_REGEXS.reduce(text) do |updated_text, regex| updated_text.gsub(regex) do |issue_link| tag = issue_link. match(/(?<tag>(?:\#|GH-)?\d+)/i). named_captures.fetch("tag") number = tag.match(/\d+/).to_s repo = issue_link. match("#{REPO_REGEX}#{TAG_REGEX}")&. named_captures&. fetch("repo", nil) source = repo ? "https://github.com/#{repo}" : source_url "[#{repo ? (repo + tag) : tag}](#{source}/issues/#{number})" end end end