lib/github_bot/github/payload.rb
# Public: Returns the repository fork URL from the original project with the most
# recent updated forked instance first
#
# Utilizing API: https://docs.github.com/en/rest/reference/repos#forks
# Example: https://api.github.com/repos/octocat/Hello-World/forks?page=1
#
# @return [Array] The array of [String] URLs associated to the forked repositories
Returns the repository fork URL from the original project with the most
recent updated forked instance first


Returns the repository fork URL from the original project with the most recent updated forked instance first
def repository_fork_urls
        return @repository_fork_urls if @repository_fork_urls
        @repository_fork_urls =
          [].tap do |ar|
            page_count = 1
            forks_url = repository[:forks_url]
            loop do
              uri = URI.parse(forks_url)
              new_query_ar = URI.decode_www_form(String(uri.query)) << ['page', page_count]
              uri.query = URI.encode_www_form(new_query_ar)
              Rails.logger.info "#{self.class}##{__method__} retrieving #{uri}"
              json = uri.open.read
              json_response = JSON.parse(json)
              break if json_response.empty?
              json_response.each do |fork|
                ar << fork['clone_url']
              end
              page_count += 1
            end
          end
      end
def repository_fork_urls return @repository_fork_urls if @repository_fork_urls @repository_fork_urls = [ ] . tap do | ar | page_count = 1 forks_url = repository [ :forks_url ] loop do uri = URI . parse ( forks_url ) new_query_ar = URI . decode_www_form ( String ( uri . query ) ) << [ 'page' , page_count ] uri . query = URI . encode_www_form ( new_query_ar ) Rails . logger . info "#{self.class}##{__method__} retrieving #{uri}" json = uri . open . read json_response = JSON . parse ( json ) break if json_response . empty? json_response . each do | fork | ar << fork [ 'clone_url' ] end page_count += 1 end end end
Public: Returns the repository fork URL from the original project with the most
recent updated forked instance first
Public : Returns the repository fork URL from the original project with the most recent updated forked instance first
# iterate over pages of forks # iterate over each fork and capture the clone_url
The array of [String] URLs associated to the forked repositories
The array of [ String ] URLs associated to the forked repositories
Array