class Fastlane::Actions::FindCommitsAction

Public Class Methods

author() click to toggle source
# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 95
def self.author
  'Syd Srirak <sydney.srirak@outware.com.au>'
end
available_options() click to toggle source
# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 62
def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :from,
      env_name: 'FL_FIND_COMMITS_FROM',
      description:  'start commit',
      optional: true,
      default_value: ENV['FL_FIND_TICKETS_FROM'] || 'HEAD'
    ),
    FastlaneCore::ConfigItem.new(
      key: :to,
      env_name: 'FL_FIND_COMMITS_TO',
      description:  'end commit',
      optional: true,
      default_value: ENV['FL_FIND_TICKETS_TO'] || ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD'
    ),
    FastlaneCore::ConfigItem.new(
      key: :matching,
      env_name: 'FL_FIND_COMMITS_MATCHING',
      description:  'regex to only include to the change log',
      optional: true,
      default_value: ENV['FL_FIND_TICKETS_MATCHING'] || '([A-Z]+-\d+)'
    ),
    FastlaneCore::ConfigItem.new(
      key: :pretty,
      env_name: 'FL_FIND_COMMITS_PRETTY_FORMAT',
      description:  'git pretty format',
      optional: true,
      default_value: ENV['FL_FIND_TICKETS_PRETTY_FORMAT'] || '%s'
    )
  ]
end
details() click to toggle source

@!group Documentation

# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 50
def self.details
  'Extracts additional issues from the log'
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 54
def self.is_supported?(platform)
  platform == :ios
end
log(from:, to:, pretty:) click to toggle source

@!group Helpers

# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 22
def self.log(from:, to:, pretty:)
  if to.to_s.empty? || from.to_s.empty?
    UI.important('Git Tickets: log(to:, from:) cannot be nil')
    return nil
  end

  other_action.changelog_from_git_commits(
    between: [from, to],
    pretty: pretty,
    merge_commit_filtering: :exclude_merges.to_s
  )
end
output() click to toggle source
# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 58
def self.output
  [String]
end
run(params) click to toggle source
# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 4
def self.run(params)
  regex = Regexp.new(params[:matching])
  changelog = log(from: params[:from], to: params[:to], pretty: params[:pretty])

  if changelog.to_s.empty?
    UI.important('No issues found.')
    return []
  end

  tickets = tickets(log: changelog, regex: regex)
  UI.important("Additional Issues: #{tickets.join("\n")}")
  return tickets
end
tickets(log:, regex:) click to toggle source
# File lib/fastlane/plugin/cerberus/actions/find_commits_action.rb, line 35
def self.tickets(log:, regex:)
  return [] if log.to_s.empty?

  log.each_line
     .map(&:strip)
     .grep(regex)
     .flatten
     .reject(&:empty?)
     .uniq
end