Class: Fastlane::Actions::EnsureGitBranchAction

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

Overview

Raises an exception and stop the lane execution if the repo is not on a specific branch

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, sh, step_text

Class Method Details

.authorObject



39
40
41
# File 'lib/fastlane/actions/ensure_git_branch.rb', line 39

def self.author
  'dbachrach'
end

.available_optionsObject



25
26
27
28
29
30
31
32
33
# File 'lib/fastlane/actions/ensure_git_branch.rb', line 25

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :branch,
                                 env_name: "FL_ENSURE_GIT_BRANCH_NAME",
                                 description: "The branch that should be checked for",
                                 is_string: true,
                                 default_value: 'master')
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/actions/ensure_git_branch.rb', line 21

def self.description
  "Raises an exception if not on a specific git branch"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/fastlane/actions/ensure_git_branch.rb', line 43

def self.is_supported?(platform)
  true
end

.outputObject



35
36
37
# File 'lib/fastlane/actions/ensure_git_branch.rb', line 35

def self.output
  []
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/fastlane/actions/ensure_git_branch.rb', line 8

def self.run(params)
  branch = params[:branch]
  if Actions.git_branch != branch
    raise "Git is not on the `#{branch}` branch, but on `#{Actions.git_branch}`! Please ensure the repo is checked out to the correct branch.".red
  else
    Helper.log.info "Git branch is `#{branch}`, all good! 💪".green
  end
end