Class: Fastlane::Helper::ChangelogGeneratorFetcher
- Inherits:
-
Object
- Object
- Fastlane::Helper::ChangelogGeneratorFetcher
- Defined in:
- lib/fastlane/plugin/changelog_generator/helper/changelog_generator_fetcher.rb
Defined Under Namespace
Modules: SharedValues
Class Method Summary collapse
Class Method Details
.fetch_github_data(params, lane_context) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_fetcher.rb', line 11 def self.fetch_github_data(params, lane_context) Actions.verify_gem!('octokit') Octokit.auto_paginate = true labels = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS] pull_requests = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS] if labels && pull_requests UI.important "Skipping API call because labels & pull requests are cached" return labels, pull_requests end project = params[:github_project] base_branch = params[:base_branch] access_token = params[:github_api_token] issues_map = {} Octokit.issues(project, state: 'closed', access_token: access_token).each do |issue| issues_map[issue.number] = issue end # Fetch pull requests pull_requests = Octokit.pull_requests(project, state: 'closed', base: base_branch, access_token: access_token) # Remove pull requests not merged pull_requests.reject! do |pr| pr.merged_at.nil? end # Sort by merged_at pull_requests.sort_by!(&:merged_at) # Uniq labels labels = issues_map.values.map(&:labels).flatten.uniq(&:id) # Add labels to pull requests pull_requests.each do |pr| pr.label_ids = issues_map[pr.number].labels.map(&:id) end lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS] = labels lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS] = pull_requests return labels, pull_requests end |