Skip to content

Commit

Permalink
Merge pull request #9220 from dependabot/bdragon/iss-9217
Browse files Browse the repository at this point in the history
Add handling for nil `source_url` in `IssueLinker` when generating PR text
  • Loading branch information
bdragon committed Mar 6, 2024
2 parents 1494160 + 70b40a5 commit d781f4e
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class IssueLinker
/\[(?<tag>(?:\#|GH-)?\d+)\]\(\)/i
].freeze, T::Array[Regexp])

sig { returns(String) }
sig { returns(T.nilable(String)) }
attr_reader :source_url

sig { params(source_url: String).void }
sig { params(source_url: T.nilable(String)).void }
def initialize(source_url:)
@source_url = source_url
end
Expand All @@ -46,9 +46,18 @@ def link_issues(text:)
.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})"
source = if repo
"https://github.com/#{repo}"
elsif source_url
source_url
end

if source
"[#{repo ? (repo + tag) : tag}](#{source}/issues/#{number})"
else
issue_link
end
end
end
end
Expand Down

0 comments on commit d781f4e

Please sign in to comment.