marlens-github-to-jira-comment 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bae6194986a4d13250e629685cbb961010abb79d3b580a82008e531b51e30a3b
|
|
4
|
+
data.tar.gz: e58272ed06f1ef711deb64b87f55d8170caa592386cd1ba5cab34dd05380b664
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 173f94495d0b30583e10917641d54bd3b99eae3f9c9f4346cfd1ea27f4eef14f0f4cfe26a2795c560d736a0fadbc422a9c50a02cfbb4b282506b5abe1455e41c
|
|
7
|
+
data.tar.gz: 84ebbd9d39e9cdf93ef883efb54f5da343fce689b4a6e5ce43d83762b0333027cf3ae14701c7d54a4c72b8f6688b6b06e438fa7df750a8f74d1ab5e7d071204e
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Marlens
|
|
4
4
|
module GithubToJiraComment
|
|
5
5
|
class CommentPoster
|
|
6
|
-
DEFAULT_IMAGE_HOSTS = ["private-user-images.githubusercontent.com"].freeze
|
|
6
|
+
DEFAULT_IMAGE_HOSTS = ["github.com", "private-user-images.githubusercontent.com", "user-images.githubusercontent.com"].freeze
|
|
7
7
|
|
|
8
8
|
def initialize(jira_client:)
|
|
9
9
|
@jira_client = jira_client
|
|
@@ -18,10 +18,11 @@ module Marlens
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def create(issue_key:, markdown:, allowed_image_hosts: [])
|
|
21
|
+
hosts = (DEFAULT_IMAGE_HOSTS + allowed_image_hosts).uniq
|
|
21
22
|
@jira_client.create_markdown_comment(
|
|
22
23
|
issue_key:,
|
|
23
24
|
markdown:,
|
|
24
|
-
allowed_image_hosts
|
|
25
|
+
allowed_image_hosts: hosts,
|
|
25
26
|
strict_images: true,
|
|
26
27
|
image_upload_failures: []
|
|
27
28
|
)
|
|
@@ -28,8 +28,8 @@ module Marlens
|
|
|
28
28
|
|
|
29
29
|
rendered_images = rendered_image_urls(render_markdown(markdown, context:)).select { |url| rendered_attachment?(url) }
|
|
30
30
|
mappings = {}
|
|
31
|
-
attachment_images.
|
|
32
|
-
rendered =
|
|
31
|
+
attachment_images.each do |image|
|
|
32
|
+
rendered = mappings[image.url] || rendered_images.find { |url| url.include?(github_attachment_id(image.url)) }
|
|
33
33
|
raise "GitHub Markdown render did not return an image for #{image.url}" unless rendered
|
|
34
34
|
|
|
35
35
|
mappings[image.url] ||= rendered
|
|
@@ -127,6 +127,10 @@ module Marlens
|
|
|
127
127
|
false
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
+
def github_attachment_id(url)
|
|
131
|
+
URI.parse(url).path.split("/").last
|
|
132
|
+
end
|
|
133
|
+
|
|
130
134
|
def host(url)
|
|
131
135
|
URI.parse(url).host
|
|
132
136
|
rescue URI::InvalidURIError
|