Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed May 8, 2024
1 parent 471562a commit 17f8694
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions steps/discover-repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@

raise 'Can only retrieve up to 1000 repos' if opts[:total] > max

puts "Trying to find #{opts[:total]} repos in GitHub"
size = [opts[:page_size], opts[:total]].min
puts "Taking up to #{size} repos per one GitHub API request"
licenses = [
'mit',
'apache-2.0',
Expand Down Expand Up @@ -101,10 +103,12 @@ def cooldown(opts, found)
sleep opts[:pause]
end

puts 'Not searching GitHub API, using mock repos' if opts[:dry]
loop do
break if page * size > max
count = 0
json = if opts[:dry] then mock_reps(page, size, licenses)
json = if opts[:dry]
mock_reps(page, size, licenses)
else
github.search_repositories(query, per_page: size, page: page)
end
Expand All @@ -127,7 +131,7 @@ def cooldown(opts, found)
puts "Found #{i[:full_name].inspect} GitHub repo ##{found.count} \
(#{i[:forks_count]} forks, #{i[:stargazers_count]} stars) with license: #{i[:license][:key]}"
end
puts "Found #{count} repositories in page ##{page}"
puts "Found #{count} good repositories in page ##{page} (out of #{json[:items].count})"
break if found.count >= opts[:total]
cooldown(opts, found)
page += 1
Expand Down

0 comments on commit 17f8694

Please sign in to comment.