# Prerequisites:
#
# * Add pronto, pronto-rubocop, and any other pronto runners to Gemfile's
# development group (TODO: how to run using standalone gems?)
# Add dotenv to project's Gemfile, if necessary (dotenv-rails includes
# it by default)
# * Create a GitHub API token: https://github.com/settings/tokens.
# Give it the following scopes: repo, repo:status
# See this tutorial for more info:
# https://christoph.luppri.ch/articles/2017/03/05/how-to-automatically-review-your-prs-for-style-violations-with-pronto-and-rubocop/
class PR < Thor
include Thor::Actions
# Usage:
# Note pull request ID in the GitHub UI or URL
# cd path/to/app
# git checkout <branch-to-review>
# thor pr:review
desc "review", "automated code review for style guide issues"
def review
if (token = ENV["PRONTO_GITHUB_ACCESS_TOKEN"])
puts "PRONTO_GITHUB_ACCESS_TOKEN found in ENV"
else
token = ask "GitHub access token:"
end
id = ask "Pull request ID:"
base = ask "Base for comparison:", default: "origin/master"
run "PRONTO_GITHUB_ACCESS_TOKEN=#{token} PULL_REQUEST_ID=#{id} pronto run -f github_status github_pr -c #{base}"
end
end