-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2dcfc1e
commit 73d6a94
Showing
5 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "active_support" | ||
require "awesome_print" | ||
require "whirly" | ||
|
||
require_relative "../lib/config" | ||
require_relative "../lib/spinner" | ||
|
||
require_relative "../lib/pulls" | ||
require_relative "../lib/repository" | ||
require_relative "../lib/reviews" | ||
|
||
require_relative "../lib/formatter" | ||
|
||
|
||
Config.initialize! | ||
|
||
raise Config::ConfigurationError, "Access token is required" if Config.access_token.nil? | ||
raise Config::ConfigurationError, "Repository is required" if Config.repositories.empty? | ||
|
||
puts "Fetching pull requests..." | ||
puts "Fetching pull requests for #{Config.repositories}..." if Config.log_level == :debug | ||
puts "Fetching pull requests for #{Config.repositories.join(", ")}..." if Config.repositories.size > 1 | ||
|
||
pulls = Config.repositories.flat_map.with_index do |name, index| | ||
puts "Fetching pull requests for #{name}... #{index + 1}/#{Config.repositories.size}" + " " * 10 + "\r" if Config.repositories.size > 1 | ||
pulls = Spinner.start do | ||
Config.repositories.flat_map.with_index do |name, index| | ||
Whirly.status = if Config.repositories.one? | ||
"Fetching pull requests..." | ||
else | ||
"Fetching pull requests #{name}... (#{index + 1}/#{Config.repositories.size})" | ||
end | ||
|
||
Repository.new(name:).pulls | ||
Repository.new(name:).pulls | ||
end | ||
end | ||
puts | ||
puts "Found #{pulls.size} pull requests." | ||
|
||
reviews = | ||
reviews = Spinner.start do | ||
pulls.flat_map.with_index do |pull, index| | ||
puts "Fetching reviews for all pull requests... #{index + 1}/#{pulls.size}" + " " * 10 + "\r" | ||
Whirly.status = "Fetching reviews... (#{index + 1}/#{pulls.size})" | ||
|
||
Reviews.for(pull:) | ||
end | ||
end | ||
puts "Found #{reviews.size} reviews." | ||
puts | ||
|
||
puts Formatter.new(reviews).to_table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "whirly" | ||
|
||
module Spinner | ||
extend self | ||
|
||
def start | ||
result = nil | ||
|
||
Whirly.start(spinner: "dots", stop: "✔") do | ||
result = yield | ||
end | ||
|
||
result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "spinner" | ||
|
||
RSpec.describe Spinner do | ||
before do | ||
allow(Whirly).to receive(:start).and_yield | ||
end | ||
|
||
it "shows the spinner" do | ||
described_class.start { "result" } | ||
|
||
expect(Whirly).to have_received(:start).with(spinner: "dots", stop: "✔") | ||
end | ||
|
||
it "returns the result of the block" do | ||
expect(described_class.start { "result" }) | ||
.to eq("result") | ||
end | ||
end |