Class: Prreview::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/prreview.rb

Constant Summary collapse

DEFAULT_PROMPT =
"Your task is to review this pull request.\nPatch lines starting with `-` are deleted.\nPatch lines starting with `+` are added.\nFocus on new problems, not ones that were already there.\nDo you see any problems?\n"
DEFAULT_LINKED_ISSUES_LIMIT =
5
URL_REGEX =

url or owner/repo#123 or #123

%r{
  https?://github\.com/
    (?<owner>[\w.-]+) /
    (?<repo>[\w.-]+) /
    (?:pull|issues) /
    (?<number>\d+)
  |
  (?:
    (?<owner>[\w.-]+) /
    (?<repo>[\w.-]+)
  )?
  \#
  (?<number>\d+)
}x

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



39
40
41
42
43
# File 'lib/prreview.rb', line 39

def initialize
  parse_options!
  parse_url!
  initialize_client
end

Instance Method Details

#processObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/prreview.rb', line 45

def process
  load_optional_files
  begin
    fetch_pr
    fetch_linked_issues
  rescue Octokit::Unauthorized
    abort 'Error: Invalid GITHUB_TOKEN.'
  rescue Octokit::NotFound
    abort 'Error: Pull request not found.'
  end
  build_xml
  copy_result_to_clipboard
end