mirror of
https://github.com/wavetermdev/homebrew-cask.git
synced 2026-08-05 13:43:24 -07:00
cask-pr-local-check: improve with optparse (#82084)
This commit is contained in:
@@ -1,12 +1,32 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
require 'open-uri'
|
||||
require 'optparse'
|
||||
require 'tmpdir'
|
||||
|
||||
# Options
|
||||
ARGV.push('--help') if ARGV.empty?
|
||||
|
||||
OptionParser.new do |opt|
|
||||
opt.banner = <<~BANNER
|
||||
Run `brew cask` `audi` and `style` checks locally, from a pull request URL.
|
||||
Useful when online CI is broken.
|
||||
|
||||
Usage:
|
||||
#{File.basename($PROGRAM_NAME)} <pr url>
|
||||
|
||||
Options:
|
||||
BANNER
|
||||
|
||||
opt.on('-h', '--help', 'Show this help.') do
|
||||
puts opt
|
||||
exit 0
|
||||
end
|
||||
end.parse!
|
||||
|
||||
pr_url = ARGV[0]
|
||||
|
||||
abort 'You need to give the script exactly one argument, the URL to a pull request from an official Homebrew Cask tap' if pr_url.nil?
|
||||
abort 'URL is not from an official Homebrew Cask tap' if pr_url !~ %r{^https://github.com/Homebrew/homebrew-cask.*}
|
||||
|
||||
pr_api = pr_url.sub(%r{^https://github.com/([^/]+)/([^/]+)/pull/([^/]+).*}, 'https://api.github.com/repos/\1/\2/pulls/\3/files')
|
||||
|
||||
Reference in New Issue
Block a user