prreview 0.4.0 → 0.5.1
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/README.md +4 -3
- data/lib/prreview/version.rb +1 -1
- data/lib/prreview.rb +29 -9
- 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: 28b817e16bf9a5637315d36b0dd477f851a80a03c1aa61988fdb521de6458dae
|
4
|
+
data.tar.gz: 44da1b71ce4de6cfe5ec280ee5eda07559ba28d2c5e9fcfda8a52fe30f9af899
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d0092f74f555b89c2bc43c3badc141219c66b7f95c36e7084994ad3ed979abd997935454b141feb5ee72b20a0a75949b0260d062f84a04669f088592529369
|
7
|
+
data.tar.gz: cf0b141c62a2142417a784b42a9c9f323ec10406b378c5dfb998d53bc27a6245e0e8a4556a009e85510ca546a07462629d28d10a136da871f68dfa9336e53c70
|
data/README.md
CHANGED
@@ -11,14 +11,14 @@ gem install prreview
|
|
11
11
|
Run this command with a PR URL:
|
12
12
|
|
13
13
|
```sh
|
14
|
-
prreview
|
14
|
+
prreview https://github.com/owner/repo/pull/123
|
15
15
|
```
|
16
16
|
|
17
17
|
Or use more options:
|
18
18
|
|
19
19
|
```
|
20
20
|
prreview --help
|
21
|
-
prreview
|
21
|
+
prreview https://github.com/owner/repo/pull/123 --all-content --prompt "Are there any security issues?"
|
22
22
|
```
|
23
23
|
|
24
24
|
Now, just paste the PR details into ChatGPT, Claude, or any LLM for review.
|
@@ -57,7 +57,8 @@ However, in the future we might add some optional integrations.
|
|
57
57
|
## Requirements
|
58
58
|
|
59
59
|
- Ruby
|
60
|
-
- `GITHUB_TOKEN` environment
|
60
|
+
- `GITHUB_TOKEN` environment
|
61
|
+
variable. [GitHub Docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
|
61
62
|
|
62
63
|
## License
|
63
64
|
|
data/lib/prreview/version.rb
CHANGED
data/lib/prreview.rb
CHANGED
@@ -37,8 +37,14 @@ module Prreview
|
|
37
37
|
|
38
38
|
def process
|
39
39
|
load_optional_files
|
40
|
-
|
41
|
-
|
40
|
+
begin
|
41
|
+
fetch_pull_request
|
42
|
+
fetch_linked_issues
|
43
|
+
rescue Octokit::Unauthorized
|
44
|
+
abort 'Error: Invalid GITHUB_TOKEN.'
|
45
|
+
rescue Octokit::NotFound
|
46
|
+
abort 'Error: Pull request not found.'
|
47
|
+
end
|
42
48
|
build_xml
|
43
49
|
copy_result_to_clipboard
|
44
50
|
end
|
@@ -54,9 +60,13 @@ module Prreview
|
|
54
60
|
ARGV << '--help' if ARGV.empty?
|
55
61
|
|
56
62
|
OptionParser.new do |parser|
|
57
|
-
parser.banner =
|
63
|
+
parser.banner = <<~BAN
|
64
|
+
Usage: #{File.basename($PROGRAM_NAME)} URL [options]
|
65
|
+
|
66
|
+
Pull request URL example: https://github.com/owner/repo/pull/1
|
67
|
+
|
68
|
+
BAN
|
58
69
|
|
59
|
-
parser.on('-u', '--url URL', 'Pull‑request URL (https://github.com/owner/repo/pull/1)') { |v| @url = v }
|
60
70
|
parser.on('-p', '--prompt PROMPT', 'Custom LLM prompt') { |v| @prompt = v }
|
61
71
|
parser.on('-a', '--all-content', 'Include full file contents') { @include_content = true }
|
62
72
|
parser.on('-l', '--limit LIMIT', Integer, "Limit number of issues fetched (default: #{DEFAULT_LINKED_ISSUES_LIMIT})") { |v| @linked_issues_limit = v }
|
@@ -73,10 +83,12 @@ module Prreview
|
|
73
83
|
end
|
74
84
|
parser.parse!
|
75
85
|
end
|
86
|
+
|
87
|
+
@url = ARGV.first
|
76
88
|
end
|
77
89
|
|
78
90
|
def parse_url!
|
79
|
-
abort 'Error: Pull
|
91
|
+
abort 'Error: Pull request URL missing.' if @url.to_s.empty?
|
80
92
|
|
81
93
|
match = @url.match(URL_REGEX)
|
82
94
|
abort 'Error: Invalid URL format. See --help for usage.' unless match
|
@@ -92,8 +104,6 @@ module Prreview
|
|
92
104
|
abort 'Error: GITHUB_TOKEN is not set.' if access_token.to_s.empty?
|
93
105
|
|
94
106
|
@client = Octokit::Client.new(access_token:, auto_paginate: true)
|
95
|
-
rescue Octokit::Unauthorized
|
96
|
-
abort 'Error: Invalid GITHUB_TOKEN.'
|
97
107
|
end
|
98
108
|
|
99
109
|
def fetch_pull_request
|
@@ -106,7 +116,7 @@ module Prreview
|
|
106
116
|
{
|
107
117
|
filename: file.filename,
|
108
118
|
patch: file.patch || '(no patch data)',
|
109
|
-
content: @include_content ? fetch_file_content(file.filename) : '(no content)'
|
119
|
+
content: @include_content && !skip_file?(file.filename) ? fetch_file_content(file.filename) : '(no content)'
|
110
120
|
}
|
111
121
|
end
|
112
122
|
end
|
@@ -210,7 +220,7 @@ module Prreview
|
|
210
220
|
x.file do
|
211
221
|
x.filename file[:filename]
|
212
222
|
x.content file[:content]
|
213
|
-
x.patch file
|
223
|
+
x.patch extract_patch(file)
|
214
224
|
end
|
215
225
|
end
|
216
226
|
end
|
@@ -244,6 +254,16 @@ module Prreview
|
|
244
254
|
@xml = builder.doc.root.to_xml
|
245
255
|
end
|
246
256
|
|
257
|
+
def extract_patch(file)
|
258
|
+
return if skip_file?(file[:filename])
|
259
|
+
|
260
|
+
file[:patch]
|
261
|
+
end
|
262
|
+
|
263
|
+
def skip_file?(filename)
|
264
|
+
File.extname(filename) == '.svg'
|
265
|
+
end
|
266
|
+
|
247
267
|
def binary?(string)
|
248
268
|
string.include?("\x00")
|
249
269
|
end
|