Class: Fastlane::Actions::FetchMergedTasksAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



68
69
70
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 68

def self.authors
  ['Semen Kologrivov']
end

.available_optionsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 45

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :last_release_tag,
                                 description: 'Tag of the last release',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :feature_branches_regexp,
                                 description: 'Regular expression that matching feature branches names',
                                 optional: true,
                                 default_value: /^(.)*\/(task)\/(\d)+_(.)*$/,
                                 type: Regexp),
    FastlaneCore::ConfigItem.new(key: :already_with_prefix,
                                 description: 'Does feature branches names have prefix from project\'s identifier (like IOS, WIL, WEST etc.)',
                                 optional: true,
                                 default_value: false,
                                 type: Boolean)
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 37

def self.description
  'Fetch merged into current branch feature tasks after last release tag'
end

.detailsObject



41
42
43
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 41

def self.details
  ''
end

.example_codeObject



76
77
78
79
80
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 76

def self.example_code
  [
    'fetch_merged_tasks(last_release_tag: "build/1.0.0(35)")'
  ]
end

.is_supported?(_) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 72

def self.is_supported?(_)
  true
end

.return_typeObject



82
83
84
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 82

def self.return_type
  :string
end

.return_valueObject



64
65
66
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 64

def self.return_value
  'Returns tasks identifiers'
end

.run(params) ⇒ Object



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
35
# File 'lib/fastlane/plugin/sequenia_gitflow/actions/fetch_merged_tasks_action.rb', line 7

def self.run(params)
  last_tag = params[:last_release_tag]
  first_commit = Helper::SequeniaGitflowHelper.first_commit
  regexp = params[:feature_branches_regexp]
  already_with_prefix = params[:already_with_prefix]

  if !last_tag.nil? && !Helper::SequeniaGitflowHelper.tag_exist?(last_tag)
    UI.user_error!("Tag '#{last_tag}' doesn't exist")
  end

  all_branch_commits = Helper::SequeniaGitflowHelper.current_branch_all_commit_hashes(last_tag || first_commit)
  merge_commits = Helper::SequeniaGitflowHelper.current_branch_merge_commit_hashes(last_tag || first_commit)

  branches = Helper::SequeniaGitflowHelper.fetch_merged_task_branches(
    all_branch_commits,
    merge_commits,
    regexp
  )
  value = branches.map do |b|
    components = b.split('/').last.split('_')
    already_with_prefix ? "#{components[0]}_#{components[1]}" : components[0]
  end
                  .sort
                  .uniq
  return value
rescue => ex
  UI.error(ex)
  UI.error('Failed')
end