Skip to content

Commit

Permalink
feat(yegor256#228): rescue NotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jul 1, 2024
1 parent d976526 commit 0a8ea92
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions steps/discover-repos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,21 @@ def cooldown(opts, found)
end

def files_in_repo(github, repo, ref, path = '')
contents = github.contents(repo, { path: path, ref: ref })
count = 0
contents.each do |content|
if content[:type] == 'file'
count += 1
elsif content[:type] == 'dir'
count += files_in_repo(github, repo, ref, content[:path])
begin
contents = github.contents(repo, { path: path, ref: ref })
count = 0
contents.each do |content|
if content[:type] == 'file'
count += 1
elsif content[:type] == 'dir'
count += files_in_repo(github, repo, ref, content[:path])
end
end
count
rescue Octokit::NotFound
puts "There is no contents inside #{repo}"
count
end
count
end

puts 'Not searching GitHub API, using mock repos' if opts[:dry]
Expand Down

0 comments on commit 0a8ea92

Please sign in to comment.