prreview 0.4.0 → 0.5.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: 714f7802004de97bfd9e4defb9f447ad5b445ea77e12b8f04123218a6684549b
4
- data.tar.gz: ce62752c1d1d11c13f432e0c74df032873088d75018a13dec4dfc658b5ed6c73
3
+ metadata.gz: 30200431f3796fe13f702beef779421ce9eb7cbb759bf05a781374d39dc4082b
4
+ data.tar.gz: cc6bbba926af7d7632a97d17551c045ead9b95b5e6682d988de20eef46d1f06b
5
5
  SHA512:
6
- metadata.gz: 7526eaadf9570e7ad2967a2e003989b3126bff0ae2d0907d4d4056f92b90f8e2e7dff91a17cef9cd8a6cd81625d20a0cf27dcb378a348f6e1f7708124952011f
7
- data.tar.gz: b9a446c787e170bb3998211173e198d5cb67480512446ddbb9f0a7620a8233ec692f8493bed7c1e1b4a181968c8e6b1ee07f1a4838ddd515c300ef60ef18bddf
6
+ metadata.gz: 44622bc990c7059044df282588707f489814ab86c6b47eff1d64379809430061de7851d7f6455212a0f5155b76331538d0fc8fe366f9f18a56cf913e2487f9a0
7
+ data.tar.gz: e5281db6c13f7b36532e663cda11eeddc0bd540a598327e7e8e4a256b24addb1879f9758f4b2150c18a86e172a3e28e4c4989c31277c4297a3577dcc40e280bf
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 -u https://github.com/owner/repo/pull/123
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 --url https://github.com/owner/repo/pull/123 --all-content --prompt "Are there any security issues?"
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 variable
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prreview
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
data/lib/prreview.rb CHANGED
@@ -37,8 +37,14 @@ module Prreview
37
37
 
38
38
  def process
39
39
  load_optional_files
40
- fetch_pull_request
41
- fetch_linked_issues
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 = "Usage: #{File.basename($PROGRAM_NAME)} -u URL [options]"
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-request URL missing. Use -u or --url.' if @url.to_s.empty?
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
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgenii Morozov