prreview 0.6.0 → 0.7.0
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 +4 -4
- data/lib/prreview/version.rb +1 -1
- data/lib/prreview.rb +25 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b7c0932a902f7945386447266e75f47c548440c6dba6f4df12120a7e1f798d8
|
4
|
+
data.tar.gz: 3ce6c0071493576b4a40763193797668206471b87d28a5d08ca74c37a720c0d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b549fb10017f52ee23154662ce1f28271f385e8771e607b9c736e2e5295327ff5389792bcdd4f6e55e9d490cc9e7ec2de04781bd4de4dc249865090e4d96d0d9
|
7
|
+
data.tar.gz: 8393b54c91c0c81dc8da1c9a7d7f39d864d455dd63b46ff4a7614783da90ff83554fc2a5daeca5aaee24b62ec54ecafb0d7c997ff5611a51db2355574f7596f0
|
data/lib/prreview/version.rb
CHANGED
data/lib/prreview.rb
CHANGED
@@ -128,7 +128,9 @@ module Prreview
|
|
128
128
|
|
129
129
|
content = @client.contents(@full_repo, path:, ref: @pr.head.sha)
|
130
130
|
decoded = Base64.decode64(content.content)
|
131
|
-
binary?(decoded)
|
131
|
+
return if binary?(decoded)
|
132
|
+
|
133
|
+
decoded
|
132
134
|
rescue Octokit::NotFound
|
133
135
|
'(file content not found)'
|
134
136
|
end
|
@@ -207,7 +209,7 @@ module Prreview
|
|
207
209
|
x.current_date DateTime.now
|
208
210
|
|
209
211
|
x.pull_request do
|
210
|
-
build_issue(x, @pr)
|
212
|
+
build_issue!(x, @pr)
|
211
213
|
|
212
214
|
x.commits do
|
213
215
|
@pr_commits.each do |c|
|
@@ -222,7 +224,7 @@ module Prreview
|
|
222
224
|
x.comments do
|
223
225
|
@pr_comments.each do |c|
|
224
226
|
x.comment_ do
|
225
|
-
build_comment(x, c)
|
227
|
+
build_comment!(x, c)
|
226
228
|
end
|
227
229
|
end
|
228
230
|
end
|
@@ -230,7 +232,7 @@ module Prreview
|
|
230
232
|
x.code_comments do
|
231
233
|
@pr_code_comments.each do |c|
|
232
234
|
x.code_comment do
|
233
|
-
build_comment(x, c)
|
235
|
+
build_comment!(x, c)
|
234
236
|
x.path c.path
|
235
237
|
x.line c.line
|
236
238
|
end
|
@@ -240,12 +242,12 @@ module Prreview
|
|
240
242
|
x.pull_request_files do
|
241
243
|
@pr_files.each do |f|
|
242
244
|
content = fetch_file_content(f.filename) if @include_content && !skip_file?(f.filename)
|
243
|
-
patch = extract_patch(f)
|
245
|
+
patch = extract_patch(f)
|
244
246
|
|
245
247
|
x.file do
|
246
248
|
x.filename f.filename
|
247
|
-
x.content(content) if content
|
248
|
-
x.patch patch
|
249
|
+
x.content { cdata!(x, content) } if content
|
250
|
+
x.patch { cdata!(x, patch) } if patch
|
249
251
|
end
|
250
252
|
end
|
251
253
|
end
|
@@ -257,12 +259,12 @@ module Prreview
|
|
257
259
|
comments = linked_issue[:comments]
|
258
260
|
|
259
261
|
x.linked_issue do
|
260
|
-
build_issue(x, issue)
|
262
|
+
build_issue!(x, issue)
|
261
263
|
|
262
264
|
x.comments do
|
263
265
|
comments.each do |c|
|
264
266
|
x.comment_ do
|
265
|
-
build_comment(x, c)
|
267
|
+
build_comment!(x, c)
|
266
268
|
end
|
267
269
|
end
|
268
270
|
end
|
@@ -275,7 +277,7 @@ module Prreview
|
|
275
277
|
@optional_file_contents.each do |file|
|
276
278
|
x.file do
|
277
279
|
x.filename file[:filename]
|
278
|
-
x.content file[:content]
|
280
|
+
x.content { cdata!(x, file[:content]) }
|
279
281
|
end
|
280
282
|
end
|
281
283
|
end
|
@@ -289,7 +291,7 @@ module Prreview
|
|
289
291
|
@xml = builder.doc.root.to_xml
|
290
292
|
end
|
291
293
|
|
292
|
-
def build_issue(xml, issue)
|
294
|
+
def build_issue!(xml, issue)
|
293
295
|
xml.url issue.html_url
|
294
296
|
xml.user issue.user.login
|
295
297
|
xml.title issue.title
|
@@ -297,7 +299,7 @@ module Prreview
|
|
297
299
|
xml.created_at issue.created_at
|
298
300
|
end
|
299
301
|
|
300
|
-
def build_comment(xml, comment)
|
302
|
+
def build_comment!(xml, comment)
|
301
303
|
xml.user comment.user.login
|
302
304
|
xml.body comment.body
|
303
305
|
xml.created_at comment.created_at
|
@@ -317,6 +319,17 @@ module Prreview
|
|
317
319
|
string.include?("\x00")
|
318
320
|
end
|
319
321
|
|
322
|
+
def cdata!(x, str)
|
323
|
+
return unless str
|
324
|
+
|
325
|
+
parts = str.to_s.split(']]>')
|
326
|
+
x.cdata(parts.first || '')
|
327
|
+
parts.drop(1).each do |rest|
|
328
|
+
x.text(']]>')
|
329
|
+
x.cdata rest
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
320
333
|
def copy_result_to_clipboard
|
321
334
|
Clipboard.copy(@xml)
|
322
335
|
puts 'XML prompt generated and copied to your clipboard.'
|