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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e70c1efe8d054fde07f26a2a4830ec6d267bfcf1c1476c1acefbfda3f1a98a5
4
- data.tar.gz: 9e18b68ab00cfb79c464b03e6ccaa0e7381420d5e74cd332b6e6c35cd597d30c
3
+ metadata.gz: 9b7c0932a902f7945386447266e75f47c548440c6dba6f4df12120a7e1f798d8
4
+ data.tar.gz: 3ce6c0071493576b4a40763193797668206471b87d28a5d08ca74c37a720c0d9
5
5
  SHA512:
6
- metadata.gz: c0afeacc8f117863e7b92623d98c81e84bb765957b59f0bcffd2558dd8a978a594e4857e5ecae1172223f06554af1f8ed795bcbdfb96b2b8ec348eac1fbb24e6
7
- data.tar.gz: bc8bbafaca87a04880f2eb4fda82c5493d3eda67d61cc22840c2ad1f7dc43688a993ae6327c9b94425f1f1fadd1c5876f1a1899c710065e0f2f0d40c1a135f51
6
+ metadata.gz: b549fb10017f52ee23154662ce1f28271f385e8771e607b9c736e2e5295327ff5389792bcdd4f6e55e9d490cc9e7ec2de04781bd4de4dc249865090e4d96d0d9
7
+ data.tar.gz: 8393b54c91c0c81dc8da1c9a7d7f39d864d455dd63b46ff4a7614783da90ff83554fc2a5daeca5aaee24b62ec54ecafb0d7c997ff5611a51db2355574f7596f0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prreview
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
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) ? '(binary file)' : 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) || '(no patch data)'
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.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prreview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgenii Morozov