Class: Fastlane::Helper::ChangelogGeneratorRelease

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(labels, pull_requests, from_tag, to_tag) ⇒ ChangelogGeneratorRelease

Returns a new instance of ChangelogGeneratorRelease.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb', line 6

def initialize(labels, pull_requests, from_tag, to_tag)
  from_date = date_for_commit_with_tag(from_tag)
  to_date = date_for_commit_with_tag(to_tag)

  # Ensure dates & tags are ascending
  if from_date && to_date && from_date > to_date
    tag = from_tag
    from_tag = to_tag
    to_tag = tag

    date = from_date
    from_date = to_date
    to_date = date
  end

  @from_tag = from_tag
  @to_tag = to_tag
  @date = to_date
  @data = {}

  labels.each do |label|
    filtered_pull_requests = pull_requests.select do |pr|
      includes_label = pr.label_ids.include?(label.id)
      in_date_range = pr.merged_at && (!from_date || pr.merged_at > from_date) && (!to_date || pr.merged_at < to_date)
      includes_label && in_date_range
    end
    @data[label] = filtered_pull_requests if filtered_pull_requests.count > 0
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb', line 4

def data
  @data
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb', line 4

def date
  @date
end

#from_tagObject

Returns the value of attribute from_tag.



4
5
6
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb', line 4

def from_tag
  @from_tag
end

#to_tagObject

Returns the value of attribute to_tag.



4
5
6
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb', line 4

def to_tag
  @to_tag
end

Instance Method Details

#display_titleObject



36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb', line 36

def display_title
  if to_tag
    "[#{to_tag}] - #{date.strftime('%Y-%m-%d')}"
  else
    "[Unreleased]"
  end
end