def associate_tagged_prs(tags, prs, total)
      @fetcher.fetch_tag_shas_async(tags)

      i = 0
      prs.reject do |pr|
        found = false
        # XXX Wish I could use merge_commit_sha, but gcg doesn't currently
        # fetch that. See
        # https://developer.github.com/v3/pulls/#get-a-single-pull-request vs.
        # https://developer.github.com/v3/pulls/#list-pull-requests
        if pr["events"] && (event = pr["events"].find { |e| e["event"] == "merged" })
          # Iterate tags.reverse (oldest to newest) to find first tag of each PR.
          if (oldest_tag = tags.reverse.find { |tag| tag["shas_in_tag"].include?(event["commit_id"]) })
            pr["first_occurring_tag"] = oldest_tag["name"]
            found = true
            i += 1
            print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
          end
        else
          # Either there were no events or no merged event. Github's api can be
          # weird like that apparently. Check for a rebased comment before erroring.
          no_events_pr = associate_rebase_comment_prs(tags, [pr], total)
          raise StandardError, "No merge sha found for PR #{pr['number']} via the GitHub API" unless no_events_pr.empty?

          found = true
          i += 1
          print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
        end
        found
      end
    end
def associate_tagged_prs(tags, prs, total)
      @fetcher.fetch_tag_shas_async(tags)

      i = 0
      prs.reject do |pr|
        found = false
        # XXX Wish I could use merge_commit_sha, but gcg doesn't currently
        # fetch that. See
        # https://developer.github.com/v3/pulls/#get-a-single-pull-request vs.
        # https://developer.github.com/v3/pulls/#list-pull-requests
        if pr["events"] && (event = pr["events"].find { |e| e["event"] == "merged" })
          # Iterate tags.reverse (oldest to newest) to find first tag of each PR.
          if (oldest_tag = tags.reverse.find { |tag| tag["shas_in_tag"].include?(event["commit_id"]) })
            pr["first_occurring_tag"] = oldest_tag["name"]
            found = true
            i += 1
            print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
          end
        else
          # Either there were no events or no merged event. Github's api can be
          # weird like that apparently. Check for a rebased comment before erroring.
          no_events_pr = associate_rebase_comment_prs(tags, [pr], total)
          raise StandardError, "No merge sha found for PR #{pr['number']} via the GitHub API" unless no_events_pr.empty?

          found = true
          i += 1
          print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
        end
        found
      end
    end
Associate merged PRs by the merge SHA contained in each tag. If the
 merge_commit_sha is not found in any tag's history, skip association.

 @param [Array] tags The tags sorted by time, newest to oldest.
 @param [Array] prs The PRs to associate.
 @return [Array] PRs without their merge_commit_sha in a tag.