Class: Fastlane::Actions::ChangelogFromGitCommitsAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/changelog_from_git_commits.rb

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, sh, step_text

Class Method Details

.authorObject



72
73
74
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 72

def self.author
  ['mfurtak', 'asfalcone']
end

.available_optionsObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 42

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :between,
                                 env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_BETWEEN',
                                 description: 'Array containing two Git revision values between which to collect messages',
                                 optional: true,
                                 is_string: false,
                                 verify_block: proc do |value|
                                   raise ":between must be of type array".red unless value.kind_of?(Array)
                                   raise ":between must be an array of size 2".red unless (value || []).size == 2
                                 end),
    FastlaneCore::ConfigItem.new(key: :pretty,
                                 env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_PRETTY',
                                 description: 'The format applied to each commit while generating the collected value',
                                 optional: true,
                                 default_value: '%B',
                                 is_string: true),
    FastlaneCore::ConfigItem.new(key: :match_lightweight_tag,
                                 env_name: 'FL_CHANGELOG_FROM_GIT_COMMITS_MATCH_LIGHTWEIGHT_TAG',
                                 description: 'Whether or not to match a lightweight tag when searching for the last one',
                                 optional: true,
                                 default_value: true,
                                 is_string: false)
  ]
end

.descriptionObject



30
31
32
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 30

def self.description
  "Collect git commit messages into a changelog"
end

.detailsObject



34
35
36
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 34

def self.details
  "By default, messages will be collected back to the last tag, but the range can be controlled"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 76

def self.is_supported?(platform)
  true
end

.outputObject



38
39
40
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 38

def self.output
  ['FL_CHANGELOG', 'The changelog String generated from the collected Git commit messages']
end

.return_valueObject



68
69
70
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 68

def self.return_value
  "Returns a String containing your formatted git commits"
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/actions/changelog_from_git_commits.rb', line 8

def self.run(params)
  if params[:between]
    from, to = params[:between]
  else
    from = Actions.last_git_tag_name(params[:match_lightweight_tag])
    Helper.log.debug "Found the last Git tag: #{from}"
    to = 'HEAD'
  end

  Helper.log.info "Collecting Git commits between #{from} and #{to}".green

  changelog = Actions.git_log_between(params[:pretty], from, to)
  changelog = changelog.gsub("\n\n", "\n") if changelog # as there are duplicate newlines
  Actions.lane_context[SharedValues::FL_CHANGELOG] = changelog

  changelog
end